• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  * Description: header file for netbuf adapter.
15  * Create: 2022-04-06
16  */
17 
18 #ifndef OAL_NETBUFF_EXT_H
19 #define OAL_NETBUFF_EXT_H
20 
21 #include "oal_skbuff.h"
22 #include "td_type.h"
23 #include "securec.h"
24 #include "oal_netbuf_common_rom.h"
25 #include "oal_types.h"
26 
27 /* oal_netbuf.h */
28 #define ETH_P_CONTROL                       0x0016      /* Card specific control frames */
29 #define OAL_NETBUF_SUCC                     0
30 #define OAL_NETBUF_FAIL                     (-1)
31 
32 
33 #define OAL_NETBUF_NEXT(_pst_buf)                   ((_pst_buf)->next)
34 #define OAL_NETBUF_PREV(_pst_buf)                   ((_pst_buf)->prev)
35 #define OAL_NETBUF_HEAD_NEXT(_pst_buf_head)         ((_pst_buf_head)->next)
36 #define OAL_NETBUF_HEAD_PREV(_pst_buf_head)         ((_pst_buf_head)->prev)
37 
38 #define OAL_NETBUF_PROTOCOL(_pst_buf)               ((_pst_buf)->protocol)
39 #define OAL_NETBUF_DATA(_pst_buf)                   ((_pst_buf)->data)
40 #define OAL_NETBUF_HEADER(_pst_buf)                 ((_pst_buf)->data)
41 #define OAL_NETBUF_PAYLOAD(_pst_buf)                 ((_pst_buf)->data)
42 
43 #define OAL_NETBUF_CB(_pst_buf)                     ((_pst_buf)->cb)
44 #define OAL_NETBUF_CB_SIZE()                        (sizeof(((oal_netbuf_stru*)0)->cb))
45 #define OAL_NETBUF_LEN(_pst_buf)                    ((_pst_buf)->len)
46 #define OAL_NETBUF_PRIORITY(_pst_buf)               ((_pst_buf)->priority)
47 #define OAL_NETBUF_TAIL                              skb_tail_pointer
48 #define OAL_NETBUF_QUEUE_TAIL                        skb_queue_tail
49 #define OAL_NETBUF_QUEUE_HEAD_INIT                   skb_queue_head_init
50 #define OAL_NETBUF_DEQUEUE                           skb_dequeue
51 
52 #define WLAN_MEM_NETBUF_ALIGN               4       /* netbuf对齐 */
53 
54 oal_netbuf_stru* oal_netbuf_alloc(td_u32 size, td_u32 l_reserve, td_u32 align);
55 td_u32 oal_netbuf_free(oal_netbuf_stru *netbuf);
56 td_void oal_netbuf_free_any(oal_netbuf_stru *netbuf);
57 
58 #define OAL_MEM_NETBUF_ALLOC(subpool_id, len, netbuf_priority) \
59     oal_netbuf_alloc(len, 0, WLAN_MEM_NETBUF_ALIGN)
60 
61 typedef struct {
62     oal_netbuf_head_stru                  buff_header;   /* netbuf队列头结点 */
63     osal_u32                              mpdu_cnt;       /* 队列中报文数量 */
64 } oal_netbuf_queue_header_stru;
65 
oal_netbuf_alloc_ext(td_u32 size)66 static inline oal_netbuf_stru* oal_netbuf_alloc_ext(td_u32 size)
67 {
68     return oal_netbuf_alloc(size + OAL_HDR_TOTAL_LEN, OAL_HDR_TOTAL_LEN - OAL_MAX_MAC_HDR_LEN, WLAN_MEM_NETBUF_ALIGN);
69 }
70 
oal_netbuf_payload(const oal_netbuf_stru * netbuf)71 static inline td_u8* oal_netbuf_payload(const oal_netbuf_stru *netbuf)
72 {
73     return netbuf->data;
74 }
75 
oal_netbuf_payload_const(const oal_netbuf_stru * netbuf)76 static inline const td_u8* oal_netbuf_payload_const(const oal_netbuf_stru *netbuf)
77 {
78     return netbuf->data;
79 }
80 
oal_netbuf_cb(const oal_netbuf_stru * netbuf)81 static inline td_u8* oal_netbuf_cb(const oal_netbuf_stru *netbuf)
82 {
83     return (td_u8 *)netbuf->cb;
84 }
85 
oal_netbuf_cb_const(const oal_netbuf_stru * netbuf)86 static inline const td_u8* oal_netbuf_cb_const(const oal_netbuf_stru *netbuf)
87 {
88     return (td_u8 *)netbuf->cb;
89 }
90 
oal_netbuf_data(oal_netbuf_stru * netbuf)91 static inline td_u8* oal_netbuf_data(oal_netbuf_stru *netbuf)
92 {
93     return netbuf->data;
94 }
95 
oal_netbuf_data_offset(oal_netbuf_stru * netbuf,td_u32 offset)96 static inline td_u8* oal_netbuf_data_offset(oal_netbuf_stru *netbuf, td_u32 offset)
97 {
98     return netbuf->data + offset;
99 }
100 
oal_netbuf_header(const oal_netbuf_stru * netbuf)101 static inline td_u8* oal_netbuf_header(const oal_netbuf_stru *netbuf)
102 {
103     return netbuf->data;
104 }
105 
oal_netbuf_header_const(const oal_netbuf_stru * netbuf)106 static inline const td_u8* oal_netbuf_header_const(const oal_netbuf_stru *netbuf)
107 {
108     return netbuf->data;
109 }
110 
111 /*****************************************************************************
112 功能描述  : 获取将skb的数据长度
113 *****************************************************************************/
oal_netbuf_get_len(oal_netbuf_stru * netbuf)114 static inline td_u32  oal_netbuf_get_len(oal_netbuf_stru *netbuf)
115 {
116     return netbuf->len;
117 }
118 
oal_netbuf_copy_queue_mapping(oal_netbuf_stru * netbuf_to,const oal_netbuf_stru * netbuf_from)119 static inline td_void oal_netbuf_copy_queue_mapping(oal_netbuf_stru *netbuf_to,
120     const oal_netbuf_stru *netbuf_from)
121 {
122     skb_copy_queue_mapping(netbuf_to, netbuf_from);
123 }
124 
125 
126 /*****************************************************************************
127 功能描述  : 在缓冲区尾部增加数据
128 *****************************************************************************/
oal_netbuf_put(oal_netbuf_stru * netbuf,td_u32 len)129 static inline td_u8* oal_netbuf_put(oal_netbuf_stru *netbuf, td_u32 len)
130 {
131     return skb_put(netbuf, len);
132 }
133 
134 /*****************************************************************************
135 功能描述  : 在缓冲区开头增加数据
136 *****************************************************************************/
oal_netbuf_push(oal_netbuf_stru * netbuf,td_u32 len)137 static inline td_u8*  oal_netbuf_push(oal_netbuf_stru *netbuf, td_u32 len)
138 {
139     return skb_push(netbuf, len);
140 }
141 
oal_netbuf_pull(oal_netbuf_stru * netbuf,td_u32 len)142 static inline td_u8* oal_netbuf_pull(oal_netbuf_stru *netbuf, td_u32 len)
143 {
144     if (len > netbuf->len) {
145         return TD_NULL;
146     }
147     return skb_pull(netbuf, len);
148 }
149 
150 /*****************************************************************************
151  功能描述  : 链接skb list前一个成员--DMAC
152 *****************************************************************************/
oal_set_netbuf_prev(oal_netbuf_stru * netbuf,oal_netbuf_stru * prev)153 static inline td_void oal_set_netbuf_prev(oal_netbuf_stru *netbuf, oal_netbuf_stru *prev)
154 {
155     netbuf->prev = prev;
156 }
157 
158 /*****************************************************************************
159  功能描述  : 链接skb list下一个成员--DMAC
160 *****************************************************************************/
oal_set_netbuf_next(oal_netbuf_stru * netbuf,oal_netbuf_stru * next)161 static inline td_void oal_set_netbuf_next(oal_netbuf_stru *netbuf,  oal_netbuf_stru *next)
162 {
163     if (netbuf == TD_NULL) {
164         return;
165     } else {
166         netbuf->next = next;
167     }
168 }
169 
170 /*****************************************************************************
171  功能描述  : 取skb list下一个成员--DMAC
172 *****************************************************************************/
oal_get_netbuf_next(oal_netbuf_stru * netbuf)173 static inline oal_netbuf_stru* oal_get_netbuf_next(oal_netbuf_stru *netbuf)
174 {
175     return netbuf->next;
176 }
177 
178 /*****************************************************************************
179  功能描述  : 判断skb list是否为空--DMAC
180 *****************************************************************************/
oal_netbuf_list_empty(const oal_netbuf_head_stru * list_head)181 static inline td_s32  oal_netbuf_list_empty(const oal_netbuf_head_stru* list_head)
182 {
183     return skb_queue_empty(list_head);
184 }
185 
186 /*****************************************************************************
187  功能描述  : 将报文结构体的data指针和tail指针同时下移
188 *****************************************************************************/
oal_netbuf_reserve(oal_netbuf_stru * netbuf,td_u32 l_len)189 static inline td_void  oal_netbuf_reserve(oal_netbuf_stru *netbuf, td_u32 l_len)
190 {
191     skb_reserve(netbuf, l_len);
192 }
193 
194 /*****************************************************************************
195  功能描述  : 判断一个skb是否为克隆的,是则copy一份新的skb,否则直接返回传入的skb
196 *****************************************************************************/
oal_netbuf_unshare(oal_netbuf_stru * netbuf,td_u32 pri)197 static inline oal_netbuf_stru* oal_netbuf_unshare(oal_netbuf_stru *netbuf, td_u32 pri)
198 {
199     return skb_unshare(netbuf, pri);
200 }
201 
202 /*****************************************************************************
203  功能描述  : 获取头部空间大小
204 *****************************************************************************/
oal_netbuf_headroom(const oal_netbuf_stru * netbuf)205 static inline td_u32  oal_netbuf_headroom(const oal_netbuf_stru *netbuf)
206 {
207     return (td_u32)skb_headroom(netbuf);
208 }
209 
210 /*****************************************************************************
211  功能描述  : 获取尾部空间大小
212 *****************************************************************************/
oal_netbuf_tailroom(const oal_netbuf_stru * netbuf)213 static inline td_u32  oal_netbuf_tailroom(const oal_netbuf_stru *netbuf)
214 {
215     return (td_u32)skb_tailroom(netbuf);
216 }
217 
218 /*****************************************************************************
219  功能描述  : 将skb加入skb链表中的尾部--DMAC
220 *****************************************************************************/
oal_netbuf_add_to_list_tail(oal_netbuf_stru * netbuf,oal_netbuf_head_stru * head)221 static inline td_void  oal_netbuf_add_to_list_tail(oal_netbuf_stru *netbuf, oal_netbuf_head_stru* head)
222 {
223     skb_queue_tail(head, netbuf);
224 }
225 
226 /*****************************************************************************
227  功能描述  : skb链表出队--DMAC
228 *****************************************************************************/
oal_netbuf_delist(oal_netbuf_head_stru * list_head)229 static inline oal_netbuf_stru* oal_netbuf_delist(oal_netbuf_head_stru *list_head)
230 {
231     return skb_dequeue(list_head);
232 }
233 
234 /*****************************************************************************
235  功能描述  : skb链表取出其中skb--DMAC
236 *****************************************************************************/
oal_netbuf_unlink(oal_netbuf_stru * netbuf,oal_netbuf_head_stru * list_head)237 static inline void oal_netbuf_unlink(oal_netbuf_stru *netbuf, oal_netbuf_head_stru *list_head)
238 {
239     skb_unlink(netbuf, list_head);
240 }
241 
242 /*****************************************************************************
243  功能描述  : 初始化skb队列头--DMAC
244 *****************************************************************************/
oal_netbuf_list_head_init(oal_netbuf_head_stru * list_head)245 static inline td_void  oal_netbuf_list_head_init(oal_netbuf_head_stru* list_head)
246 {
247     skb_queue_head_init(list_head);
248 }
249 
250 /*****************************************************************************
251  功能描述  : 返回链表中指定节点的下一个节点
252 
253 *****************************************************************************/
oal_netbuf_list_next(const oal_netbuf_stru * netbuf)254 static inline oal_netbuf_stru* oal_netbuf_list_next(const oal_netbuf_stru *netbuf)
255 {
256     return netbuf->next;
257 }
258 /*****************************************************************************
259  功能描述  : add a netbuf to skb list
260 
261 *****************************************************************************/
oal_netbuf_list_tail(oal_netbuf_head_stru * list,oal_netbuf_stru * netbuf)262 static inline td_void oal_netbuf_list_tail(oal_netbuf_head_stru* list, oal_netbuf_stru *netbuf)
263 {
264     skb_queue_tail(list, netbuf);
265 }
266 
oal_netbuf_list_tail_nolock(oal_netbuf_head_stru * list,oal_netbuf_stru * newsk)267 static inline td_void oal_netbuf_list_tail_nolock(oal_netbuf_head_stru *list, oal_netbuf_stru *newsk)
268 {
269     __skb_queue_tail(list, newsk);
270 }
271 
272 /*****************************************************************************
273  功能描述  : join two skb lists and reinitialise the emptied list
274 *****************************************************************************/
oal_netbuf_splice_init(oal_netbuf_head_stru * list,oal_netbuf_head_stru * head)275 static inline td_void oal_netbuf_splice_init(oal_netbuf_head_stru* list, oal_netbuf_head_stru* head)
276 {
277     skb_queue_splice_init(list, head);
278 }
279 
280 /*****************************************************************************
281  功能描述  :  join two skb lists and reinitialise the emptied list
282 *****************************************************************************/
oal_netbuf_queue_splice_tail_init(oal_netbuf_head_stru * list,oal_netbuf_head_stru * head)283 static inline td_void oal_netbuf_queue_splice_tail_init(oal_netbuf_head_stru* list, oal_netbuf_head_stru* head)
284 {
285     skb_queue_splice_tail_init(list, head);
286 }
287 
288 /*****************************************************************************
289 功能描述  : init netbuf list
290 *****************************************************************************/
oal_netbuf_head_init(oal_netbuf_head_stru * list)291 static inline td_void oal_netbuf_head_init(oal_netbuf_head_stru *list)
292 {
293     skb_queue_head_init(list);
294 }
295 
296 /*****************************************************************************
297 功能描述  : 返回skb链表中的第一个元素--DMAC
298 *****************************************************************************/
oal_netbuf_peek(const oal_netbuf_head_stru * head)299 static inline oal_netbuf_stru* oal_netbuf_peek(const oal_netbuf_head_stru *head)
300 {
301 #if defined(_PRE_OS_VERSION_LINUX) && defined(_PRE_OS_VERSION) && (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
302 #if defined(LINUX_VERSION_CODE) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
303     return skb_peek(head);
304 #else
305     oal_netbuf_stru *skb = head->next;
306     if (skb == (oal_netbuf_stru *)head)
307         skb = NULL;
308     return skb;
309 #endif
310 #endif
311 #if defined(_PRE_OS_VERSION_LITEOS) && defined(_PRE_OS_VERSION) && (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION)
312     return skb_peek(head);
313 #endif
314 }
315 
316 /* ****************************************************************************
317 功能描述  : 返回skb链表中的第一个元素的下一个元素--HMAC
318 **************************************************************************** */
oal_netbuf_peek_next(oal_netbuf_stru * netbuf,oal_netbuf_head_stru * head)319 static inline oal_netbuf_stru* oal_netbuf_peek_next(oal_netbuf_stru* netbuf, oal_netbuf_head_stru *head)
320 {
321 #if defined(_PRE_OS_VERSION_LINUX) && defined(_PRE_OS_VERSION) && (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
322 #if defined(LINUX_VERSION_CODE) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
323     return skb_peek_next(netbuf, head);
324 #else
325     oal_netbuf_stru *next = netbuf->next;
326     if (next == (oal_netbuf_stru *)head)
327         next = NULL;
328     return next;
329 #endif
330 #endif
331 #if defined(_PRE_OS_VERSION_LITEOS) && defined(_PRE_OS_VERSION) && (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION)
332     return skb_peek_next(netbuf, head);
333 #endif
334 }
335 
336 /*****************************************************************************
337 功能描述  : 返回skb链表中的最后一个元素
338 *****************************************************************************/
oal_netbuf_tail(const oal_netbuf_head_stru * head)339 static inline oal_netbuf_stru* oal_netbuf_tail(const oal_netbuf_head_stru *head)
340 {
341 #if defined(_PRE_OS_VERSION_LINUX) && defined(_PRE_OS_VERSION) && (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
342 #if defined(LINUX_VERSION_CODE) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
343     return skb_peek_tail(head);
344 #else
345     oal_netbuf_stru *skb = head->prev;
346     if (skb == (oal_netbuf_stru *)head)
347         skb = NULL;
348     return skb;
349 #endif
350 #endif
351 #if defined(_PRE_OS_VERSION_LITEOS) && defined(_PRE_OS_VERSION) && (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION)
352     return skb_peek_tail(head);
353 #endif
354 }
355 
356 /*****************************************************************************
357 功能描述  : 获取netbuf双向链表中buf的个数
358 *****************************************************************************/
oal_netbuf_get_buf_num(const oal_netbuf_head_stru * netbuf_head)359 static inline td_u32 oal_netbuf_get_buf_num(const oal_netbuf_head_stru *netbuf_head)
360 {
361     return netbuf_head->qlen;
362 }
363 
364 /*****************************************************************************
365 功能描述  : 将skb中的内容先偏移ul_offset后 按指定长度拷贝到指定内存中
366 *****************************************************************************/
oal_netbuf_copydata(const oal_netbuf_stru * netbuf,td_u32 offset,td_void * dst,td_u32 dst_len,td_u32 len)367 static inline td_u32 oal_netbuf_copydata(const oal_netbuf_stru *netbuf, td_u32 offset, td_void *dst,
368     td_u32 dst_len, td_u32 len)
369 {
370     const td_void *scr = oal_netbuf_payload_const(netbuf) + offset;
371 
372     if (memcpy_s(dst, dst_len, scr, len) != EOK) {
373         return OAL_NETBUF_FAIL;
374     }
375 
376     return OAL_NETBUF_SUCC;
377 }
378 
379 /*****************************************************************************
380 功能描述  : 剥去skb中尾部的信息
381 *****************************************************************************/
oal_netbuf_trim(oal_netbuf_stru * netbuf,td_u32 len)382 static inline td_void oal_netbuf_trim(oal_netbuf_stru *netbuf, td_u32 len)
383 {
384     skb_trim(netbuf, netbuf->len - len);
385 }
386 
387 /*****************************************************************************
388 功能描述  : 将skb的数据内容长度设置为指定长度
389 *****************************************************************************/
oal_netbuf_set_len(oal_netbuf_stru * netbuf,td_u32 len)390 static inline td_void oal_netbuf_set_len(oal_netbuf_stru *netbuf, td_u32 len)
391 {
392     if (netbuf->len > len) {
393         skb_trim(netbuf, len);
394     } else {
395         skb_put(netbuf, (len - netbuf->len));
396     }
397 }
398 
399 /*****************************************************************************
400 功能描述  : 初始化netbuf
401 *****************************************************************************/
oal_netbuf_init(oal_netbuf_stru * netbuf,td_u32 len)402 static inline td_void oal_netbuf_init(oal_netbuf_stru *netbuf, td_u32 len)
403 {
404     oal_netbuf_set_len(netbuf, len);
405     netbuf->protocol = ETH_P_CONTROL;
406 }
407 
408 /*****************************************************************************
409 功能描述: 获取netbuf 链表长度--DMAC
410 *****************************************************************************/
oal_netbuf_list_len(const oal_netbuf_head_stru * head)411 static inline td_u32 oal_netbuf_list_len(const oal_netbuf_head_stru *head)
412 {
413     return skb_queue_len(head);
414 }
415 
416 /*****************************************************************************
417  功能描述  : 删除链表中的skb.(只有链表头有next 和 pre,所以只能依次从头删)
418 *****************************************************************************/
oal_netbuf_delete(oal_netbuf_stru * buf,oal_netbuf_head_stru * list_head)419 static inline td_void oal_netbuf_delete(oal_netbuf_stru *buf, oal_netbuf_head_stru *list_head)
420 {
421     skb_unlink(buf, list_head);
422 }
423 
424 /* oal_netbuf.c */
425 /*****************************************************************************
426  功能描述  : 获取当前netbuf元素后的第n个元素
427  输入参数  : (1)起始查找节点
428              (2)向后查找的个数
429  输出参数  : 指向期望的netbuf的指针
430  返 回 值  : 期望的betbuf元素的指针或空指针
431 *****************************************************************************/
oal_netbuf_get_appointed_netbuf(oal_netbuf_stru * netbuf,td_u8 num,oal_netbuf_stru ** expect_netbuf)432 static inline td_u32 oal_netbuf_get_appointed_netbuf(oal_netbuf_stru *netbuf, td_u8 num,
433     oal_netbuf_stru** expect_netbuf)
434 {
435     td_u8 buf_num;
436 
437     if ((netbuf == TD_NULL) || (expect_netbuf == TD_NULL)) {
438         return OAL_NETBUF_FAIL;
439     }
440 
441     *expect_netbuf = TD_NULL;
442     for (buf_num = 0; buf_num < num; buf_num++) {
443         *expect_netbuf = oal_get_netbuf_next(netbuf);
444 
445         if (*expect_netbuf == TD_NULL) {
446             break;
447         }
448 
449         netbuf = *expect_netbuf;
450     }
451 
452     return OAL_NETBUF_SUCC;
453 }
454 
455 /*****************************************************************************
456  功能描述  : 向netbu_head的尾部串接netbuf
457 *****************************************************************************/
oal_netbuf_concat(oal_netbuf_stru * netbuf_head,oal_netbuf_stru * netbuf)458 static inline td_u32 oal_netbuf_concat(oal_netbuf_stru* netbuf_head, oal_netbuf_stru* netbuf)
459 {
460     if (skb_is_nonlinear(netbuf_head)) {
461         oal_netbuf_free(netbuf);
462         return OAL_NETBUF_FAIL;
463     }
464 
465     if (skb_tailroom(netbuf_head) < netbuf->len) {
466         oal_netbuf_free(netbuf);
467         return OAL_NETBUF_FAIL;
468     }
469 
470     if (memcpy_s(skb_tail_pointer(netbuf_head), netbuf->len, netbuf->data, netbuf->len)  != EOK) {
471         oal_netbuf_free(netbuf);
472         return OAL_NETBUF_FAIL;
473     }
474 
475     skb_put(netbuf_head, netbuf->len);
476     oal_netbuf_free(netbuf);
477     return OAL_NETBUF_SUCC;
478 }
479 
480 /* oal_net_rom.h */
481 /*****************************************************************************
482  功能描述  : 将skb加入skb链表(device单向链表)中的头部
483 *****************************************************************************/
oal_netbuf_addlist(oal_netbuf_head_stru * head,oal_netbuf_stru * netbuf)484 static inline td_void oal_netbuf_addlist(oal_netbuf_head_stru *head, oal_netbuf_stru *netbuf)
485 {
486     skb_queue_head(head, netbuf);
487 }
488 
489 /* oal_net.h */
oal_netbuf_expand_head(oal_netbuf_stru * netbuf,td_s32 nhead,td_s32 ntail,td_s32 gfp_mask)490 static inline td_s32 oal_netbuf_expand_head(oal_netbuf_stru *netbuf, td_s32 nhead, td_s32 ntail, td_s32 gfp_mask)
491 {
492     return pskb_expand_head(netbuf, (td_u32)nhead, (td_u32)ntail, gfp_mask);
493 }
494 
495 /* get the queue index of the input skbuff */
oal_skb_get_queue_mapping(oal_netbuf_stru * netbuf)496 static inline td_u16 oal_skb_get_queue_mapping(oal_netbuf_stru *netbuf)
497 {
498     return skb_get_queue_mapping(netbuf);
499 }
500 
oal_skb_set_queue_mapping(oal_netbuf_stru * netbuf,td_u16 queue_mapping)501 static inline td_void oal_skb_set_queue_mapping(oal_netbuf_stru *netbuf, td_u16 queue_mapping)
502 {
503     skb_set_queue_mapping(netbuf, queue_mapping);
504 }
505 
oal_netbuf_reserve_header(oal_netbuf_stru * netbuf)506 static inline td_u32 oal_netbuf_reserve_header(oal_netbuf_stru *netbuf)
507 {
508     td_u32 header_len = oal_netbuf_headroom(netbuf);
509     if (header_len < (td_u32)OAL_HDR_TOTAL_LEN) {
510         return (td_u32)oal_netbuf_expand_head(netbuf, (osal_s32)(OAL_HDR_TOTAL_LEN - header_len), 0, 0);
511     }
512     return OAL_NETBUF_SUCC;
513 }
514 #endif
515