0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
0018
0019 #include <linux/kernel.h>
0020 #include <linux/module.h>
0021
0022 #include "ath.h"
0023 #include "trace.h"
0024
0025 MODULE_AUTHOR("Atheros Communications");
0026 MODULE_DESCRIPTION("Shared library for Atheros wireless LAN cards.");
0027 MODULE_LICENSE("Dual BSD/GPL");
0028
0029 struct sk_buff *ath_rxbuf_alloc(struct ath_common *common,
0030 u32 len,
0031 gfp_t gfp_mask)
0032 {
0033 struct sk_buff *skb;
0034 u32 off;
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049 skb = __dev_alloc_skb(len + common->cachelsz - 1, gfp_mask);
0050 if (skb != NULL) {
0051 off = ((unsigned long) skb->data) % common->cachelsz;
0052 if (off != 0)
0053 skb_reserve(skb, common->cachelsz - off);
0054 } else {
0055 pr_err("skbuff alloc of size %u failed\n", len);
0056 return NULL;
0057 }
0058
0059 return skb;
0060 }
0061 EXPORT_SYMBOL(ath_rxbuf_alloc);
0062
0063 bool ath_is_mybeacon(struct ath_common *common, struct ieee80211_hdr *hdr)
0064 {
0065 return ieee80211_is_beacon(hdr->frame_control) &&
0066 !is_zero_ether_addr(common->curbssid) &&
0067 ether_addr_equal_64bits(hdr->addr3, common->curbssid);
0068 }
0069 EXPORT_SYMBOL(ath_is_mybeacon);
0070
0071 void ath_printk(const char *level, const struct ath_common* common,
0072 const char *fmt, ...)
0073 {
0074 struct va_format vaf;
0075 va_list args;
0076
0077 va_start(args, fmt);
0078
0079 vaf.fmt = fmt;
0080 vaf.va = &args;
0081
0082 if (common && common->hw && common->hw->wiphy) {
0083 printk("%sath: %s: %pV",
0084 level, wiphy_name(common->hw->wiphy), &vaf);
0085 trace_ath_log(common->hw->wiphy, &vaf);
0086 } else {
0087 printk("%sath: %pV", level, &vaf);
0088 }
0089
0090 va_end(args);
0091 }
0092 EXPORT_SYMBOL(ath_printk);
0093
0094 const char *ath_bus_type_strings[] = {
0095 [ATH_PCI] = "pci",
0096 [ATH_AHB] = "ahb",
0097 [ATH_USB] = "usb",
0098 };
0099 EXPORT_SYMBOL(ath_bus_type_strings);