Merge branch '2.6.36-fixes' of git://github.com/schandinat/linux-2.6
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / staging / otus / wrap_buf.c
CommitLineData
4bd43f50
LR
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
4bd43f50 33#include <net/iw_handler.h>
4bd43f50
LR
34
35
36/* Called to allocate buffer, must return a continue buffer space */
2bef7a0f 37zbuf_t *zfwBufAllocate(zdev_t *dev, u16_t len)
4bd43f50 38{
2bef7a0f 39 zbuf_t *buf;
4bd43f50
LR
40
41 /* Allocate SKB for packet*/
42 buf = dev_alloc_skb(len);
43
44 return buf;
45}
46
47
48/* Called to free buffer, replace below 3 functions */
2bef7a0f 49void zfwBufFree(zdev_t *dev, zbuf_t *buf, u16_t status)
4bd43f50
LR
50{
51 dev_kfree_skb_any(buf);
52}
53
54/* Called to adjust buffer size and head pointer */
2bef7a0f 55u16_t zfwBufRemoveHead(zdev_t *dev, zbuf_t *buf, u16_t size)
4bd43f50 56{
2bef7a0f 57 /* zm_assert(buf->len > size); */
4bd43f50
LR
58
59 buf->data += size;
60 buf->len -= size;
61 return 0;
62}
63
64
65
66
67/* return tail if head==NULL, called to chain multiple buffer together */
68/* Used to chain Rx buffer to form a frame. if the prepared Rx buffer */
69/* is greater than an ethernet frame(1518+32 byte), then this function */
70/* will only be called with head=NULL. */
2bef7a0f 71u16_t zfwBufChain(zdev_t *dev, zbuf_t **head, zbuf_t *tail)
4bd43f50
LR
72{
73
74 *head = tail;
75 return 0;
76}
77
78
79/* Called when doing infra-bss forwarding */
2bef7a0f 80u16_t zfwBufCopy(zdev_t *dev, zbuf_t *dst, zbuf_t *src)
4bd43f50
LR
81{
82 memcpy(dst->data, src->data, src->len);
83 dst->tail = dst->data;
84 skb_put(dst, src->len);
85 return 0;
86}
87
88
89/* Called to adjust buffer size and tail pointer */
2bef7a0f 90u16_t zfwBufSetSize(zdev_t *dev, zbuf_t *buf, u16_t size)
4bd43f50
LR
91{
92#ifdef NET_SKBUFF_DATA_USES_OFFSET
93 buf->tail = 0;
94 buf->len = 0;
95#else
96 buf->tail = buf->data;
97 buf->len = 0;
98#endif
99
100 skb_put(buf, size);
101 return 0;
102}
103
2bef7a0f 104u16_t zfwBufGetSize(zdev_t *dev, zbuf_t *buf)
4bd43f50
LR
105{
106 return buf->len;
107}
108
2bef7a0f 109void zfwCopyBufContext(zdev_t *dev, zbuf_t *source, zbuf_t *dst)
4bd43f50
LR
110{
111}