Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(339)

Side by Side Diff: chromeos/drivers/ath6kl/os/linux/netbuf.c

Issue 646055: Atheros AR600x driver + build glue (Closed)
Patch Set: Created 10 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1
2 /*
3 *
4 * Copyright (c) 2004-2007 Atheros Communications Inc.
5 * All rights reserved.
6 *
7 *
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License version 2 as
10 // published by the Free Software Foundation;
11 //
12 // Software distributed under the License is distributed on an "AS
13 // IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
14 // implied. See the License for the specific language governing
15 // rights and limitations under the License.
16 //
17 //
18 *
19 */
20 #include <linux/kernel.h>
21 #include <linux/skbuff.h>
22 #include <a_config.h>
23 #include "athdefs.h"
24 #include "a_types.h"
25 #include "a_osapi.h"
26 #include "htc_packet.h"
27
28 #define AR6000_DATA_OFFSET 64
29
30 void a_netbuf_enqueue(A_NETBUF_QUEUE_T *q, void *pkt)
31 {
32 skb_queue_tail((struct sk_buff_head *) q, (struct sk_buff *) pkt);
33 }
34
35 void a_netbuf_prequeue(A_NETBUF_QUEUE_T *q, void *pkt)
36 {
37 skb_queue_head((struct sk_buff_head *) q, (struct sk_buff *) pkt);
38 }
39
40 void *a_netbuf_dequeue(A_NETBUF_QUEUE_T *q)
41 {
42 return((void *) skb_dequeue((struct sk_buff_head *) q));
43 }
44
45 int a_netbuf_queue_size(A_NETBUF_QUEUE_T *q)
46 {
47 return(skb_queue_len((struct sk_buff_head *) q));
48 }
49
50 int a_netbuf_queue_empty(A_NETBUF_QUEUE_T *q)
51 {
52 return(skb_queue_empty((struct sk_buff_head *) q));
53 }
54
55 void a_netbuf_queue_init(A_NETBUF_QUEUE_T *q)
56 {
57 skb_queue_head_init((struct sk_buff_head *) q);
58 }
59
60 void *
61 a_netbuf_alloc(int size)
62 {
63 struct sk_buff *skb;
64 size += 2 * (A_GET_CACHE_LINE_BYTES()); /* add some cacheline space at front and back of buffer */
65 skb = dev_alloc_skb(AR6000_DATA_OFFSET + sizeof(HTC_PACKET) + size);
66 skb_reserve(skb, AR6000_DATA_OFFSET + sizeof(HTC_PACKET) + A_GET_CACHE_LINE_ BYTES());
67 return ((void *)skb);
68 }
69
70 /*
71 * Allocate an SKB w.o. any encapsulation requirement.
72 */
73 void *
74 a_netbuf_alloc_raw(int size)
75 {
76 struct sk_buff *skb;
77
78 skb = dev_alloc_skb(size);
79
80 return ((void *)skb);
81 }
82
83 void
84 a_netbuf_free(void *bufPtr)
85 {
86 struct sk_buff *skb = (struct sk_buff *)bufPtr;
87
88 dev_kfree_skb(skb);
89 }
90
91 A_UINT32
92 a_netbuf_to_len(void *bufPtr)
93 {
94 return (((struct sk_buff *)bufPtr)->len);
95 }
96
97 void *
98 a_netbuf_to_data(void *bufPtr)
99 {
100 return (((struct sk_buff *)bufPtr)->data);
101 }
102
103 /*
104 * Add len # of bytes to the beginning of the network buffer
105 * pointed to by bufPtr
106 */
107 A_STATUS
108 a_netbuf_push(void *bufPtr, A_INT32 len)
109 {
110 skb_push((struct sk_buff *)bufPtr, len);
111
112 return A_OK;
113 }
114
115 /*
116 * Add len # of bytes to the beginning of the network buffer
117 * pointed to by bufPtr and also fill with data
118 */
119 A_STATUS
120 a_netbuf_push_data(void *bufPtr, char *srcPtr, A_INT32 len)
121 {
122 skb_push((struct sk_buff *) bufPtr, len);
123 A_MEMCPY(((struct sk_buff *)bufPtr)->data, srcPtr, len);
124
125 return A_OK;
126 }
127
128 /*
129 * Add len # of bytes to the end of the network buffer
130 * pointed to by bufPtr
131 */
132 A_STATUS
133 a_netbuf_put(void *bufPtr, A_INT32 len)
134 {
135 skb_put((struct sk_buff *)bufPtr, len);
136
137 return A_OK;
138 }
139
140 /*
141 * Add len # of bytes to the end of the network buffer
142 * pointed to by bufPtr and also fill with data
143 */
144 A_STATUS
145 a_netbuf_put_data(void *bufPtr, char *srcPtr, A_INT32 len)
146 {
147 char *start = ((struct sk_buff *)bufPtr)->data +
148 ((struct sk_buff *)bufPtr)->len;
149 skb_put((struct sk_buff *)bufPtr, len);
150 A_MEMCPY(start, srcPtr, len);
151
152 return A_OK;
153 }
154
155
156 /*
157 * Trim the network buffer pointed to by bufPtr to len # of bytes
158 */
159 A_STATUS
160 a_netbuf_setlen(void *bufPtr, A_INT32 len)
161 {
162 skb_trim((struct sk_buff *)bufPtr, len);
163
164 return A_OK;
165 }
166
167 /*
168 * Chop of len # of bytes from the end of the buffer.
169 */
170 A_STATUS
171 a_netbuf_trim(void *bufPtr, A_INT32 len)
172 {
173 skb_trim((struct sk_buff *)bufPtr, ((struct sk_buff *)bufPtr)->len - len);
174
175 return A_OK;
176 }
177
178 /*
179 * Chop of len # of bytes from the end of the buffer and return the data.
180 */
181 A_STATUS
182 a_netbuf_trim_data(void *bufPtr, char *dstPtr, A_INT32 len)
183 {
184 char *start = ((struct sk_buff *)bufPtr)->data +
185 (((struct sk_buff *)bufPtr)->len - len);
186
187 A_MEMCPY(dstPtr, start, len);
188 skb_trim((struct sk_buff *)bufPtr, ((struct sk_buff *)bufPtr)->len - len);
189
190 return A_OK;
191 }
192
193
194 /*
195 * Returns the number of bytes available to a a_netbuf_push()
196 */
197 A_INT32
198 a_netbuf_headroom(void *bufPtr)
199 {
200 return (skb_headroom((struct sk_buff *)bufPtr));
201 }
202
203 /*
204 * Removes specified number of bytes from the beginning of the buffer
205 */
206 A_STATUS
207 a_netbuf_pull(void *bufPtr, A_INT32 len)
208 {
209 skb_pull((struct sk_buff *)bufPtr, len);
210
211 return A_OK;
212 }
213
214 /*
215 * Removes specified number of bytes from the beginning of the buffer
216 * and return the data
217 */
218 A_STATUS
219 a_netbuf_pull_data(void *bufPtr, char *dstPtr, A_INT32 len)
220 {
221 A_MEMCPY(dstPtr, ((struct sk_buff *)bufPtr)->data, len);
222 skb_pull((struct sk_buff *)bufPtr, len);
223
224 return A_OK;
225 }
226
227 #ifdef EXPORT_HCI_BRIDGE_INTERFACE
228 EXPORT_SYMBOL(a_netbuf_to_data);
229 EXPORT_SYMBOL(a_netbuf_put);
230 EXPORT_SYMBOL(a_netbuf_pull);
231 EXPORT_SYMBOL(a_netbuf_alloc);
232 EXPORT_SYMBOL(a_netbuf_free);
233 #endif
OLDNEW
« no previous file with comments | « chromeos/drivers/ath6kl/os/linux/ioctl.c ('k') | chromeos/drivers/ath6kl/os/linux/wireless_ext.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698