| Christian Lamparter | a1c5558 | 2009-04-14 22:11:20 +0200 | [diff] [blame] | 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 | #include <linux/kernel.h> | 
 | 18 | #include <linux/module.h> | 
 | 19 |  | 
| Luis R. Rodriguez | d15dd3e | 2009-08-12 09:56:59 -0700 | [diff] [blame] | 20 | #include "ath.h" | 
 | 21 |  | 
| Christian Lamparter | a1c5558 | 2009-04-14 22:11:20 +0200 | [diff] [blame] | 22 | MODULE_AUTHOR("Atheros Communications"); | 
 | 23 | MODULE_DESCRIPTION("Shared library for Atheros wireless LAN cards."); | 
 | 24 | MODULE_LICENSE("Dual BSD/GPL"); | 
| Luis R. Rodriguez | d15dd3e | 2009-08-12 09:56:59 -0700 | [diff] [blame] | 25 |  | 
 | 26 | struct sk_buff *ath_rxbuf_alloc(struct ath_common *common, | 
 | 27 | 				u32 len, | 
 | 28 | 				gfp_t gfp_mask) | 
 | 29 | { | 
 | 30 | 	struct sk_buff *skb; | 
 | 31 | 	u32 off; | 
 | 32 |  | 
 | 33 | 	/* | 
 | 34 | 	 * Cache-line-align.  This is important (for the | 
 | 35 | 	 * 5210 at least) as not doing so causes bogus data | 
 | 36 | 	 * in rx'd frames. | 
 | 37 | 	 */ | 
 | 38 |  | 
 | 39 | 	/* Note: the kernel can allocate a value greater than | 
 | 40 | 	 * what we ask it to give us. We really only need 4 KB as that | 
 | 41 | 	 * is this hardware supports and in fact we need at least 3849 | 
 | 42 | 	 * as that is the MAX AMSDU size this hardware supports. | 
 | 43 | 	 * Unfortunately this means we may get 8 KB here from the | 
 | 44 | 	 * kernel... and that is actually what is observed on some | 
 | 45 | 	 * systems :( */ | 
 | 46 | 	skb = __dev_alloc_skb(len + common->cachelsz - 1, gfp_mask); | 
 | 47 | 	if (skb != NULL) { | 
 | 48 | 		off = ((unsigned long) skb->data) % common->cachelsz; | 
 | 49 | 		if (off != 0) | 
 | 50 | 			skb_reserve(skb, common->cachelsz - off); | 
 | 51 | 	} else { | 
 | 52 | 		printk(KERN_ERR "skbuff alloc of size %u failed\n", len); | 
 | 53 | 		return NULL; | 
 | 54 | 	} | 
 | 55 |  | 
 | 56 | 	return skb; | 
 | 57 | } | 
 | 58 | EXPORT_SYMBOL(ath_rxbuf_alloc); | 
| Joe Perches | 21a99f9 | 2010-12-02 19:12:35 -0800 | [diff] [blame] | 59 |  | 
| Joe Perches | 29e7624 | 2011-08-26 01:56:39 -0700 | [diff] [blame] | 60 | void ath_printk(const char *level, const char *fmt, ...) | 
| Joe Perches | 21a99f9 | 2010-12-02 19:12:35 -0800 | [diff] [blame] | 61 | { | 
 | 62 | 	struct va_format vaf; | 
 | 63 | 	va_list args; | 
| Joe Perches | 21a99f9 | 2010-12-02 19:12:35 -0800 | [diff] [blame] | 64 |  | 
 | 65 | 	va_start(args, fmt); | 
 | 66 |  | 
 | 67 | 	vaf.fmt = fmt; | 
 | 68 | 	vaf.va = &args; | 
 | 69 |  | 
| Joe Perches | 29e7624 | 2011-08-26 01:56:39 -0700 | [diff] [blame] | 70 | 	printk("%sath: %pV", level, &vaf); | 
| Joe Perches | 21a99f9 | 2010-12-02 19:12:35 -0800 | [diff] [blame] | 71 |  | 
 | 72 | 	va_end(args); | 
| Joe Perches | 21a99f9 | 2010-12-02 19:12:35 -0800 | [diff] [blame] | 73 | } | 
 | 74 | EXPORT_SYMBOL(ath_printk); |