2 ******************************************************************************
6 * @brief sdio core definitions
8 * Copyright (C) ESWIN 2015-2020
10 ******************************************************************************
17 #include <linux/completion.h>
18 #include <linux/if_ether.h>
20 #include <net/mac80211.h>
21 #include "ecrnx_compat.h"
24 #define ESWIN_FLAG_CORE_REGISTERED 1
26 #define ESWIN_NR_VIF 2
27 #define ESWIN_NR_VIF_HW_QUEUE 4
30 #define ESWIN_STATE_BOOT 1
31 #define ESWIN_STATE_INIT 2
32 #define ESWIN_STATE_STOP 3
33 #define ESWIN_STATE_CLOSING 4
34 #define ESWIN_STATE_CLOSEED 5
35 #define ESWIN_STATE_START 6
36 #define ESWIN_STATE_RUNNING 7
38 #define SDIO_PKG_MAX_BIT 9
39 #define SDIO_PKG_MAX_CNT 4//4/3
40 #define SDIO_PKG_BIT_SHIFT (SDIO_PKG_MAX_BIT/SDIO_PKG_MAX_CNT)
41 #define SDIO_PKG_PAD_GRN (512)//512/256
42 #define SDIO_PKG_DIV_MSZ (1024)//1024/1536
43 #define SDIO_DATA_MTU (1500)
44 #define SDIO_PKG_MAX_DATA (SDIO_DATA_MTU + ECRNX_TX_TXDESC_API_ALIGN)
47 #define WIM_RESP_TIMEOUT (msecs_to_jiffies(100))
49 enum ESWIN_SCAN_MODE {
50 ESWIN_SCAN_MODE_IDLE = 0,
51 ESWIN_SCAN_MODE_SCANNING,
52 ESWIN_SCAN_MODE_ABORTING,
60 uint32_t tx_head_size;
61 uint32_t rx_head_size;
62 uint32_t payload_align;
66 struct eswin_capabilities {
68 uint16_t listen_interval;
69 uint16_t bss_max_idle;
70 uint8_t bss_max_idle_options;
73 struct eswin_max_idle {
78 struct timer_list keep_alive_timer;
80 unsigned long idle_period; /* jiffies */
81 struct timer_list timer;
85 /* Private txq driver data structure */
87 u16 hw_queue; /* 0: AC_BK, 1: AC_BE, 2: AC_VI, 3: AC_VO */
88 struct list_head list;
89 struct sk_buff_head queue; /* own queue */
90 unsigned long nr_fw_queueud;
91 unsigned long nr_push_allowed;
92 struct ieee80211_vif vif;
93 struct ieee80211_sta sta;
97 struct tx_buff_node * next;
103 struct tx_buff_queue {
104 struct tx_buff_node * head;
105 struct tx_buff_node * tail;
110 struct tx_buff_pkg_node {
111 struct tx_buff_pkg_node * next;
115 struct tx_buff_node * tx_node[SDIO_PKG_MAX_CNT];
119 struct tx_buff_pkg_queue {
120 struct tx_buff_pkg_node * head;
121 struct tx_buff_pkg_node * tail;
126 struct tx_buff_pkg_head {
127 unsigned int len[SDIO_PKG_MAX_CNT];
130 #define ESWIN_QUEUE_MAX (ESWIN_NR_VIF_HW_QUEUE*ESWIN_NR_VIF + 3)
131 #define ESWIN_TX_NODE_CNT 64
133 typedef int (*sdio_rx_cb_t)(void *priv, struct sk_buff *skb);
134 typedef int (*sdio_data_cfm_cb_t)(void *priv, void *host_id);
137 void *umac_priv; //mac drv data.
138 struct ieee80211_hw *hw;
139 struct ieee80211_vif *vif[ESWIN_NR_VIF];
146 bool ampdu_supported;
148 bool amsdu_supported;
155 const struct sdio_ops *ops;
156 sdio_rx_cb_t rx_callback;
157 sdio_data_cfm_cb_t data_cfm_callback;
158 sdio_data_cfm_cb_t msg_cfm_callback;
160 //struct sx_buff_queue queue[ESWIN_NR_VIF]; /* 0: frame, 1: wim */
161 struct tx_buff_queue tx_queue;
162 struct tx_buff_pkg_queue tx_c_queue;
163 struct tx_buff_pkg_queue tx_pkg_queue;
164 struct tx_buff_node tx_node[ESWIN_TX_NODE_CNT];
165 struct tx_buff_node * tx_node_head;
169 struct tx_buff_pkg_node tx_pkg_node[ESWIN_TX_NODE_CNT];
170 struct tx_buff_pkg_node * tx_pkg_node_head;
171 spinlock_t tx_pkg_lock;
174 struct work_struct work;
175 struct work_struct work_c;
176 struct work_struct work_pkg;
178 //struct task_struct *kthread_pkg;
179 //wait_queue_head_t wait_pkg; /* wait queue */
181 struct eswin_txq ntxq[ESWIN_QUEUE_MAX];
183 struct mutex state_mtx;
184 enum ESWIN_SCAN_MODE scan_mode;
186 struct task_struct *kthread_pkg;
187 struct task_struct *kthread_tx;
188 struct task_struct *kthread_cb;
190 wait_queue_head_t wait_pkg;
191 wait_queue_head_t wait_tx;
192 wait_queue_head_t wait_cb;
194 struct delayed_work scan_timeout;
196 //struct work_struct register_work;
197 struct delayed_work register_work;
200 unsigned long dev_flags;
201 struct mac_address mac_addr[ESWIN_NR_VIF];
202 struct ieee80211_supported_band bands[NUM_NL80211_BANDS];
206 /* Move to vif or sta driver data */
215 struct fwinfo_t fwinfo;
216 struct eswin_capabilities cap;
218 /* power management */
225 bool ps_poll_pending;
232 struct list_head txq;
233 /* 0: AC_BK, 1: AC_BE, 2: AC_VI, 3: AC_VO */
234 atomic_t tx_credit[IEEE80211_NUM_ACS*3];
235 atomic_t tx_pend[IEEE80211_NUM_ACS*3];
237 // struct completion wim_responded;
238 // struct sk_buff *last_wim_responded;
241 struct delayed_work roc_finish;
245 struct dentry *debugfs;
248 u8 drv_priv[0] __aligned(sizeof(void *));
252 /* vif driver data structure */
256 struct net_device *dev;
259 struct delayed_work scan_timeout;
265 spinlock_t preassoc_sta_lock;
266 struct list_head preassoc_sta_list;
272 #define to_ieee80211_vif(v) \
273 container_of((void *)v, struct ieee80211_vif, drv_priv)
275 #define to_i_vif(v) ((struct eswin_vif *) (v)->drv_priv)
277 static inline int hw_vifindex(struct ieee80211_vif *vif)
279 struct eswin_vif *i_vif;
284 i_vif = to_i_vif(vif);
288 /* sta driver data structure */
291 struct ieee80211_vif *vif;
292 /*struct ieee80211_sta *sta;*/
294 enum ieee80211_sta_state state;
295 struct list_head list;
298 struct ieee80211_key_conf *ptk;
299 struct ieee80211_key_conf *gtk;
301 /* BSS max idle period */
302 struct eswin_capabilities cap;
303 struct eswin_max_idle max_idle;
306 #define to_ieee80211_sta(s) \
307 container_of((void *)s, struct ieee80211_sta, drv_priv)
309 #define to_i_sta(s) ((struct eswin_sta *) (s)->drv_priv)
313 struct eswin_sta_handler {
314 int (*sta_state)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
315 struct ieee80211_sta *sta,
316 enum ieee80211_sta_state old_state,
317 enum ieee80211_sta_state new_state);
323 static struct eswin_sta_handler __stah_ ## fn \
324 __attribute((__used__)) \
325 __attribute((__section__("nrc.sta"))) = { \
329 extern struct eswin_sta_handler __sta_h_start, __sta_h_end;
335 struct eswin_trx_data {
337 struct ieee80211_vif *vif;
338 struct ieee80211_sta *sta;
344 #define NL80211_IFTYPE_ALL (BIT(NUM_NL80211_IFTYPES)-1)
348 int eswin_core_register(struct eswin *tr);
349 void eswin_core_unregister(struct eswin *tr);
351 struct eswin * eswin_core_create(size_t priv_size, struct device *dev,
352 const struct sdio_ops * ops);
354 void eswin_core_destroy(struct eswin *tr);
357 extern int power_save;
358 extern int disable_cqm;
359 #ifdef CONFIG_ECRNX_WIFO_CAIL
360 extern bool amt_mode;
362 extern bool set_gain;