• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
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  */
15 #ifndef __WIFI_AGENT_H__
16 #define __WIFI_AGENT_H__
17 
18 #include "net_defs.h"
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 #if defined(CP_BOOT) && defined(WIFI_ON_CP) && defined(WAGT_SYNC_ENABLE)
25 #define WAGT_DATA	SRAM_DATA_LOC
26 #define WAGT_BSS	SRAM_BSS_LOC
27 extern uint8_t *wagt_sync_ptr;
28 #define WAGT_SYNC_BUF(buf) wagt_sync_ptr
29 #define WAGT_SYNC_BUF_OUT(buf, len) {memcpy(wagt_sync_ptr, (buf), (len));}
30 #define WAGT_SYNC_BUF_IN(buf, len) {memcpy((buf), wagt_sync_ptr, (len));}
31 #else
32 #define WAGT_DATA
33 #define WAGT_BSS
34 #define WAGT_SYNC_BUF(buf) (buf)
35 #define WAGT_SYNC_BUF_OUT(buf, len)
36 #define WAGT_SYNC_BUF_IN(buf, len)
37 #endif
38 
39 #define IPC_DEBUG_ENABLE       (0)
40 #define IPC_DATA_SIZE          (72)
41 #define IPC_DATA_NUM           (64)
42 #define WIFI_DATAIN_NUM        (64)
43 #define WIFI_DATAOUT_NUM       (32)
44 #define WIFI_DATAOUT_SIZE      (SKB_TX_DATA_SIZE)
45 #define SEND2PEER_TRY_CNT      (100)
46 #define WIFI_HEARTBEAT_TIMEOUT (8000) // 8s
47 #define WIFI_HEARTBEAT_PERIOD  (2000) // 2s
48 /* elements of ipc_xxx should be the same as CP_IPC_MSG_HDR's */
49 typedef struct ipc_data {
50     uint16_t ipc_id;
51     uint16_t ipc_len;
52     uint16_t used;
53     uint16_t id;
54     uint16_t len;
55     uint8_t data[IPC_DATA_SIZE];
56 } IPC_DATA_T;
57 
58 typedef enum {
59     /* management message */
60     NET_IPC_MSG_PARAS = 0,
61     NET_IPC_MSG_NET_INIT,
62     NET_IPC_MSG_EPTA_CONN,
63     NET_IPC_MSG_EPTA_TTS,
64     NET_IPC_MSG_EPTA_BT,
65     NET_IPC_MSG_EPTA_PARAM,
66     NET_IPC_MSG_SCAN,
67     NET_IPC_MSG_CFG_SCAN,
68     NET_IPC_MSG_GET_SCAN_RES,
69     NET_IPC_MSG_FLUSH_SCAN_RES,
70     NET_IPC_MSG_CONN,
71     NET_IPC_MSG_DISC,
72     NET_IPC_MSG_GET_SSID,
73     NET_IPC_MSG_GET_BSSID,
74     NET_IPC_MSG_GET_MAC,
75     NET_IPC_MSG_GET_CHANNEL,
76     NET_IPC_MSG_GET_RSSI,
77     NET_IPC_MSG_GET_CURR_RATE,
78     NET_IPC_MSG_GET_LINKINFO,
79     NET_IPC_MSG_EN_NETWORK,
80     NET_IPC_MSG_EN_NETWORK_ID,
81     NET_IPC_MSG_ADD_NETWORK,
82     NET_IPC_MSG_MODIFY_NETWORK,
83     NET_IPC_MSG_CNT_CFG_SSID,
84     NET_IPC_MSG_GET_CFG,
85     NET_IPC_MSG_IFA_ADDR,
86     NET_IPC_MSG_NV_ADDNET,
87     NET_IPC_MSG_NV_GETNET,
88     NET_IPC_MSG_NV_FIND_CFG,
89     NET_IPC_MSG_DEL_ALLCFG,
90     NET_IPC_MSG_DEL_CFG,
91     NET_IPC_MSG_PS,
92     NET_IPC_MSG_SW_CH,
93     NET_IPC_MSG_STAT_EN,
94     NET_IPC_MSG_STAT_GET,
95     NET_IPC_MSG_STAT_CLR,
96     NET_IPC_MSG_AP_UP,
97     NET_IPC_MSG_AP_DOWN,
98     NET_IPC_MSG_AP_CFG,
99     NET_IPC_MSG_AP_SET_STA_NUM,
100     NET_IPC_MSG_AP_SET_COUNTRY,
101     NET_IPC_MSG_AP_ADD_VENDOR_IE,
102     NET_IPC_MSG_AP_GET_STA_INFO,
103     NET_IPC_MSG_WPS_WILD_OK,
104     NET_IPC_MSG_WPS_PBC,
105     NET_IPC_MSG_EVENT_NOTIFY,
106     NET_IPC_MSG_SET_FIX_RATE,
107     /* debug: not printf the ipc id */
108     NET_IPC_MSG_HEARTBEAT,
109     NET_IPC_MSG_SNIFF_STT,
110     NET_IPC_MSG_SNIFF_STP,
111     NET_IPC_MSG_SNIFF_FLT,
112     NET_IPC_MSG_SNIFF_CH,
113     NET_IPC_MSG_MAC_RECV,
114     NET_IPC_MSG_SNIFF_RCV,
115 
116     /* data message */
117     NET_IPC_MSG_MAC_XMIT,
118     NET_IPC_MSG_SEND_MLME,
119     NET_IPC_MSG_ALLOC_SKB,
120 #ifdef CSI_REPORT
121     NET_IPC_MSG_CSI_INFO,
122 #endif
123     /* last message */
124     NET_IPC_MSG_NUM,
125 } NET_IPC_MSG_T;
126 
127 typedef enum {
128     INFO_ASYN = 0,
129     INFO_SYN = 1,
130 } NET_IPC_SYN_T;
131 
132 typedef enum {
133     IPC_SEND_ERROR              = -1,
134     IPC_STATUS_NOT_READY        = -50,
135 } IPC_STATUS_T;
136 
137 typedef enum {
138     WIFI_AGENT_UNINIT = 0,
139     WIFI_AGENT_RESET,
140     WIFI_AGENT_READY,
141     WIFI_AGENT_NET_READY,
142 } WIFI_AGENT_STATUS_T;
143 
144 struct wifi_data_o {
145     uint32     in_use;
146     uint16     devnum;
147     uint16     data_len;
148     uint8      *data;
149     uint32     data_ptr;
150     uint32     idx;
151 };
152 
153 struct wifi_data_i {
154     uint32     in_use;
155     uint16     devnum;
156     uint16     data_len;
157     uint8      *data;
158     uint8      *skb;
159 };
160 
161 uint8 **wifi_agent_get_tx_buf(void);
162 int wifi_agent_send_tx_buf(uint8 devnum, uint8 **tx_buf, uint16 tx_len);
163 int wifi_agent_send2peer(int msg, int data_len, void *data, int sync);
164 int wifi_agent_init(void);
165 void wifi_agent_pre_reset(void);
166 void wifi_agent_reset(void);
167 void wifi_heartbeat_timer_restart(int time);
168 void wifi_heartbeat_timer_stop(void);
169 #ifdef __cplusplus
170 }
171 #endif
172 
173 #endif
174