Branch data Line data Source code
1 : : /* 2 : : * Copyright (c) 2009 Atheros Communications Inc. 3 : : * 4 : : * Permission to use, copy, modify, and/or distribute this software for any 5 : : * purpose with or without fee is hereby granted, provided that the above 6 : : * copyright notice and this permission notice appear in all copies. 7 : : * 8 : : * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 : : * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 : : * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 : : * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 : : * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 : : * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 : : * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 : : */ 16 : : 17 : : #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 18 : : 19 : : #include <linux/kernel.h> 20 : : #include <linux/module.h> 21 : : 22 : : #include "ath.h" 23 : : #include "trace.h" 24 : : 25 : : MODULE_AUTHOR("Atheros Communications"); 26 : : MODULE_DESCRIPTION("Shared library for Atheros wireless LAN cards."); 27 : : MODULE_LICENSE("Dual BSD/GPL"); 28 : : 29 : 3096 : struct sk_buff *ath_rxbuf_alloc(struct ath_common *common, 30 : : u32 len, 31 : : gfp_t gfp_mask) 32 : : { 33 : 3096 : struct sk_buff *skb; 34 : 3096 : u32 off; 35 : : 36 : : /* 37 : : * Cache-line-align. This is important (for the 38 : : * 5210 at least) as not doing so causes bogus data 39 : : * in rx'd frames. 40 : : */ 41 : : 42 : : /* Note: the kernel can allocate a value greater than 43 : : * what we ask it to give us. We really only need 4 KB as that 44 : : * is this hardware supports and in fact we need at least 3849 45 : : * as that is the MAX AMSDU size this hardware supports. 46 : : * Unfortunately this means we may get 8 KB here from the 47 : : * kernel... and that is actually what is observed on some 48 : : * systems :( */ 49 : 3096 : skb = __dev_alloc_skb(len + common->cachelsz - 1, gfp_mask); 50 [ + - ]: 3096 : if (skb != NULL) { 51 : 3096 : off = ((unsigned long) skb->data) % common->cachelsz; 52 [ - + ]: 3096 : if (off != 0) 53 : 0 : skb_reserve(skb, common->cachelsz - off); 54 : : } else { 55 : 0 : pr_err("skbuff alloc of size %u failed\n", len); 56 : 0 : return NULL; 57 : : } 58 : : 59 : : return skb; 60 : : } 61 : : EXPORT_SYMBOL(ath_rxbuf_alloc); 62 : : 63 : 18 : bool ath_is_mybeacon(struct ath_common *common, struct ieee80211_hdr *hdr) 64 : : { 65 [ - + - - ]: 18 : return ieee80211_is_beacon(hdr->frame_control) && 66 [ - + - - ]: 18 : !is_zero_ether_addr(common->curbssid) && 67 : : ether_addr_equal_64bits(hdr->addr3, common->curbssid); 68 : : } 69 : : EXPORT_SYMBOL(ath_is_mybeacon); 70 : : 71 : 95 : void ath_printk(const char *level, const struct ath_common* common, 72 : : const char *fmt, ...) 73 : : { 74 : 95 : struct va_format vaf; 75 : 95 : va_list args; 76 : : 77 : 95 : va_start(args, fmt); 78 : : 79 : 95 : vaf.fmt = fmt; 80 : 95 : vaf.va = &args; 81 : : 82 [ + - + - : 95 : if (common && common->hw && common->hw->wiphy) { + - ] 83 [ + - ]: 95 : printk("%sath: %s: %pV", 84 : : level, wiphy_name(common->hw->wiphy), &vaf); 85 : 95 : trace_ath_log(common->hw->wiphy, &vaf); 86 : : } else { 87 : 0 : printk("%sath: %pV", level, &vaf); 88 : : } 89 : : 90 : 95 : va_end(args); 91 : 95 : } 92 : : EXPORT_SYMBOL(ath_printk); 93 : : 94 : : const char *ath_bus_type_strings[] = { 95 : : [ATH_PCI] = "pci", 96 : : [ATH_AHB] = "ahb", 97 : : [ATH_USB] = "usb", 98 : : }; 99 : : EXPORT_SYMBOL(ath_bus_type_strings);