Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright (c) 2009 Atheros Communications Inc.
0003  *
0004  * Permission to use, copy, modify, and/or distribute this software for any
0005  * purpose with or without fee is hereby granted, provided that the above
0006  * copyright notice and this permission notice appear in all copies.
0007  *
0008  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
0009  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
0010  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
0011  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
0012  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
0013  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
0014  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
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      * Cache-line-align.  This is important (for the
0038      * 5210 at least) as not doing so causes bogus data
0039      * in rx'd frames.
0040      */
0041 
0042     /* Note: the kernel can allocate a value greater than
0043      * what we ask it to give us. We really only need 4 KB as that
0044      * is this hardware supports and in fact we need at least 3849
0045      * as that is the MAX AMSDU size this hardware supports.
0046      * Unfortunately this means we may get 8 KB here from the
0047      * kernel... and that is actually what is observed on some
0048      * systems :( */
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);