Merge branch 'for-linus' of git://repo.or.cz/cris-mirror
[pandora-kernel.git] / drivers / staging / otus / wrap_buf.c
1 /*
2  * Copyright (c) 2007-2008 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 /*  Module Name : wrap_buf.c                                            */
18 /*                                                                      */
19 /*  Abstract                                                            */
20 /*     This module contains wrapper functions for buffer management     */
21 /*                                                                      */
22 /*  NOTES                                                               */
23 /*     Platform dependent.                                              */
24 /*                                                                      */
25 /************************************************************************/
26
27 #include "oal_dt.h"
28 #include "usbdrv.h"
29
30
31 #include <linux/netlink.h>
32
33 #if WIRELESS_EXT > 12
34 #include <net/iw_handler.h>
35 #endif
36
37
38
39 /* Called to allocate buffer, must return a continue buffer space */
40 zbuf_t* zfwBufAllocate(zdev_t* dev, u16_t len)
41 {
42     zbuf_t* buf;
43
44     /* Allocate SKB for packet*/
45     buf = dev_alloc_skb(len);
46
47     return buf;
48 }
49
50
51 /* Called to free buffer, replace below 3 functions */
52 void zfwBufFree(zdev_t* dev, zbuf_t* buf, u16_t status)
53 {
54     dev_kfree_skb_any(buf);
55 }
56
57 /* Called to adjust buffer size and head pointer */
58 u16_t zfwBufRemoveHead(zdev_t* dev, zbuf_t* buf, u16_t size)
59 {
60     //zm_assert(buf->len > size);
61
62     buf->data += size;
63     buf->len -= size;
64     return 0;
65 }
66
67
68
69
70 /* return tail if head==NULL, called to chain multiple buffer together */
71 /* Used to chain Rx buffer to form a frame. if the prepared Rx buffer  */
72 /* is greater than an ethernet frame(1518+32 byte), then this function    */
73 /* will only be called with head=NULL.                                 */
74 u16_t zfwBufChain(zdev_t* dev, zbuf_t** head, zbuf_t* tail)
75 {
76
77     *head = tail;
78     return 0;
79 }
80
81
82 /* Called when doing infra-bss forwarding */
83 u16_t zfwBufCopy(zdev_t* dev, zbuf_t* dst, zbuf_t* src)
84 {
85     memcpy(dst->data, src->data, src->len);
86     dst->tail = dst->data;
87     skb_put(dst, src->len);
88     return 0;
89 }
90
91
92 /* Called to adjust buffer size and tail pointer */
93 u16_t zfwBufSetSize(zdev_t* dev, zbuf_t* buf, u16_t size)
94 {
95 #ifdef NET_SKBUFF_DATA_USES_OFFSET
96     buf->tail = 0;
97     buf->len = 0;
98 #else
99     buf->tail = buf->data;
100     buf->len = 0;
101 #endif
102
103     skb_put(buf, size);
104     return 0;
105 }
106
107 u16_t zfwBufGetSize(zdev_t* dev, zbuf_t* buf)
108 {
109     return buf->len;
110 }
111
112 void zfwCopyBufContext(zdev_t* dev, zbuf_t* source, zbuf_t* dst)
113 {
114 }