• 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: netbuf function.
15  * Author:
16  * Create: 2022-04-07
17  */
18 
19 #ifndef __OAL_NETBUF_H__
20 #define __OAL_NETBUF_H__
21 
22 /*****************************************************************************
23   1 其他头文件包含
24 *****************************************************************************/
25 #include "oal_skbuff.h"
26 #include "lwip/netif.h"
27 
28 /*****************************************************************************
29   2 宏定义
30 *****************************************************************************/
31 typedef struct pbuf oal_lwip_buf;
32 typedef gfp_t        oal_gfp_enum_uint8;
33 
34 /*****************************************************************************
35   3 结构体定义
36 *****************************************************************************/
37 typedef struct {
38     oal_netbuf_stru netbuf;
39     td_u8 flag;     // 1: 已申请      0:未申请
40     td_u8 direct;   // 2:TX   1:RX   0:else
41     td_u16 resv;
42 } netbuf_stru;
43 
44 #define ZERO_COPY_LWIP_DRIECT_RX 1
45 #define ZERO_COPY_LWIP_DRIECT_TX 2
46 
47 td_void oal_init_netbuf_stru(td_void);
48 oal_netbuf_stru *oal_malloc_netbuf_stru(td_u8 direct);
49 td_void oal_free_netbuf_stru(oal_netbuf_stru *netbuf);
50 td_void oal_free_netbuf_list(oal_netbuf_head_stru *list_head);
51 #ifdef _PRE_LWIP_ZERO_COPY
52 oal_netbuf_stru *oal_pbuf_netbuf_alloc(td_u32 len);
53 td_u32 oal_malloc_netbuf_used(td_u8 direct);
54 #endif
55 
56 /* 参考hmac_rx_copy_netbuff_etc */
57 oal_netbuf_stru* _oal_netbuf_copy(oal_netbuf_stru *src_netbuf, oal_gfp_enum_uint8 priority);
58 
59 #endif
60