27 #include <linux/kernel.h>
28 #include <linux/netdevice.h>
29 #include <linux/slab.h>
50 struct sk_buff *
skb = dev_alloc_skb(size + 256);
53 (
"Failed to allocate skb for hardware pool %d\n",
58 skb_reserve(skb, 256 - (((
unsigned long)skb->
data) & 0x7f));
59 *(
struct sk_buff **)(skb->
data -
sizeof(
void *)) = skb;
63 return elements - freed;
72 static void cvm_oct_free_hw_skbuff(
int pool,
int size,
int elements)
77 memory = cvmx_fpa_alloc(pool);
80 *(
struct sk_buff **)(memory -
sizeof(
void *));
87 pr_warning(
"Freeing of pool %u had too many skbuffs (%d)\n",
89 else if (elements > 0)
90 pr_warning(
"Freeing of pool %u is missing %d skbuffs\n",
102 static int cvm_oct_fill_hw_memory(
int pool,
int size,
int elements)
121 pr_warning(
"Unable to allocate %u bytes for FPA pool %d\n",
122 elements * size, pool);
125 fpa = (
char *)(((
unsigned long)memory + 256) & ~0x7f
UL);
126 *((
char **)fpa - 1) =
memory;
127 cvmx_fpa_free(fpa, pool, 0);
130 return elements - freed;
139 static void cvm_oct_free_hw_memory(
int pool,
int size,
int elements)
144 fpa = cvmx_fpa_alloc(pool);
148 memory = *((
char **)fpa - 1);
154 pr_warning(
"Freeing of pool %u had too many buffers (%d)\n",
156 else if (elements > 0)
157 pr_warning(
"Warning: Freeing of pool %u is missing %d buffers\n",
165 freed = cvm_oct_fill_hw_skbuff(pool, size, elements);
167 freed = cvm_oct_fill_hw_memory(pool, size, elements);
174 cvm_oct_free_hw_skbuff(pool, size, elements);
176 cvm_oct_free_hw_memory(pool, size, elements);