• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17  */
18 
19 #ifndef __OAL_HCC_SLAVE_IF_H
20 #define __OAL_HCC_SLAVE_IF_H
21 
22 #include "oal_net.h"
23 #include "oal_mem.h"
24 #include "hcc_comm.h"
25 #include "wlan_spec_1131h.h"
26 
27 #ifdef __cplusplus
28 #if __cplusplus
29 extern "C" {
30 #endif
31 #endif
32 
33 /* *****************************************************************************
34  * 宏定义
35  * **************************************************************************** */
36 #define HCC_LONG_PACKAGE_SIZE (WLAN_LARGE_NETBUF_SIZE)
37 #ifndef FRW_EVENT_HCC_BURST_COUNT
38 #define FRW_EVENT_HCC_BURST_COUNT 64
39 #endif
40 
41 /* *****************************************************************************
42  * 枚举定义
43  * **************************************************************************** */
44 typedef hi_void (*hcc_msg_cb)(hi_u32 msg);
45 
46 typedef enum {
47     HCC_TX_LINUX_BYPASS,
48     HCC_TX_SDIO_HOST_BYPASS,
49     HCC_TX_SDIO_SLAVE_BYPASS,
50     HCC_TX_HAL_HARDWARE_BYPASS,
51     HCC_THRUPUT_BYPASS_BUTT,
52 } hcc_thruput_bypass; /* oal_thruput_bypass_enum */
53 
54 /* 发送结构体 */
55 typedef struct {
56     hi_u32              tx_pkt_bytes;         /* 发送数据字节数 */
57     oal_dev_netbuf_stru *netbuf;
58 } hcc_slave_tx_pack;
59 
60 /* 发送方向信息结构体,Device To Host */
61 typedef struct {
62     hi_u32             aggr_tx_num;         /* TX方向聚合帧数量 */
63     hi_u32             tx_aggr_total_len;   /* TX方向聚合帧Pad之前的总长度 */
64     hcc_slave_tx_pack  hcc_tx_aggr[HISDIO_DEV2HOST_SCATT_MAX]; /* TX方向聚合帧数据 */
65 } hcc_slave_tx_info;
66 
67 /* 接收结构体 */
68 typedef struct {
69     hi_u32               rx_pkt_bytes;         /* 发送数据字节数 ,包括HCC头+PayLoad */
70     oal_dev_netbuf_stru  *netbuf;
71 } hcc_slave_rx_pack;
72 
73 /* 接收方向信息结构体, Host To Device */
74 typedef struct {
75     hi_u32             aggr_rx_num;          /* RX方向聚合帧数量 */
76     hi_u32             trans_len;            /* RX方向传输报文长度 */
77     hi_u32             rx_aggr_total_len;    /* TX方向聚合帧Pad之前的总长度 */
78     hcc_slave_rx_pack  hcc_rx_aggr[HISDIO_HOST2DEV_SCATT_MAX + 1]; /* RX方向聚合帧数据,留1个用于放置Padding数据 */
79 } hcc_slave_rx_info;
80 
81 typedef struct {
82     hi_s32               len;                /* for hcc transfer */
83     oal_dev_netbuf_stru  *net_buf;
84 } hcc_slave_netbuf;
85 
86 typedef hi_s32 (*hcc_rx_pre_do)(hi_u8 stype, hcc_slave_netbuf *net_buf, hi_u8 **pre_do_context);
87 typedef hi_s32 (*hcc_rx_post_do)(hi_u8 stype, const hcc_slave_netbuf *net_buf, hi_u8 *pre_do_context);
88 
89 typedef struct {
90     hi_u32         pkts_count;
91     hcc_rx_pre_do  pre_do;
92     hcc_rx_post_do post_do;
93     hi_void*       context;              /* the callback argument */
94 } hcc_rx_action;
95 
96 typedef struct {
97     hcc_rx_action action[HCC_ACTION_TYPE_BUTT];
98 } hcc_rx_action_info;
99 
100 struct hcc_handler {
101     hcc_rx_action_info rx_action_info;
102 };
103 
104 /* *****************************************************************************
105  * 全局变量声明
106  * **************************************************************************** */
107 /* *****************************************************************************
108   函数声明
109 ***************************************************************************** */
110 hi_u32 hcc_slave_init(hi_void);
111 hi_u32 hcc_slave_reinit(hi_void);
112 hi_void hcc_slave_clean(hi_void);
113 hi_void hcc_slave_tx_queue_sched(hi_void);
114 hi_void hcc_slave_rx_queue_sched(hi_void);
115 struct hcc_handler *hcc_get_default_handler(hi_void);
116 hi_void hcc_slave_tx(oal_dev_netbuf_stru *dev_netbuf, hi_u16 pay_load_len, const hcc_transfer_param *param);
117 hi_void hcc_register_msg_callback(hcc_msg_cb msg_callback);
118 hi_u32 hcc_rx_register(struct hcc_handler *hcc, hi_u8 mtype, hcc_rx_post_do post_do, hcc_rx_pre_do pre_do);
119 hi_u8 hcc_get_thruput_bypass_enable(hcc_thruput_bypass bypass_type);
120 hi_void hcc_set_thruput_bypass_enable(hcc_thruput_bypass bypass_type, hi_u8 value);
121 hi_u8 *hcc_get_extend_payload_addr(const oal_dev_netbuf_stru *dev_netbuf);
122 hi_void *hcc_get_extern_address(const oal_dev_netbuf_stru *dev_netbuf, hi_u32 extend_len);
123 hi_u8 *hcc_get_extend_addr(const oal_dev_netbuf_stru *dev_netbuf, hi_u32 extend_len);
124 hi_void hcc_update_high_priority_buffer_credit(hi_u8 free_large_buffer, hi_u8 free_mgmt_buffer, hi_u8 tx_dscr_free_cnt);
125 
126 #ifdef __cplusplus
127 #if __cplusplus
128 }
129 #endif
130 #endif
131 
132 #endif /* end of hcc_slave.h */
133