1 /* 2 * Common interfaces for XRadio drivers 3 * 4 * Copyright (c) 2013 5 * Xradio Technology Co., Ltd. <www.xradiotech.com> 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License version 2 as 9 * published by the Free Software Foundation. 10 */ 11 12 #ifndef XRADIO_ETF_H 13 #define XRADIO_ETF_H 14 #include <linux/version.h> 15 16 /* ETF Adapter layer */ 17 #define NL_FOR_XRADIO 30 18 /* 19 * When queue mode is enable, user space operate is non-block if items in rx_pool, 20 * but it may sleep and will drop msg when rx_pool is empty for a long time. 21 * When queue mode is disable, user space operate is block and user packet 22 * will not be drop, but driver can be panic if etf cli be kill during operate. 23 * So, for more safe in driver, enable this by default. 24 */ 25 #define ETF_QUEUEMODE 1 26 #define ETF_QUEUE_TIMEOUT 50 /* about 2s.*/ 27 28 int xradio_set_etfcli_data(int value, int index); 29 int xradio_etfcli_data_init(void); 30 31 #define ADAPTER_RX_BUF_LEN (528*3) /* pay respect for SDIO_BLOCK_SIZE*/ 32 #if (ETF_QUEUEMODE) 33 #define ADAPTER_ITEM_MAX (32) 34 #define XRADIO_ADAPTER ("xradio_etf") 35 struct adapter_item { 36 struct list_head head; 37 void *skb; 38 }; 39 #endif 40 41 typedef int (*msg_proc)(void *data, int len); 42 struct xradio_adapter { 43 struct sock *sock; 44 msg_proc handler; 45 void *msg_buf; 46 int msg_len; 47 #if (ETF_QUEUEMODE) 48 struct adapter_item rx_items[ADAPTER_ITEM_MAX]; 49 struct list_head rx_queue; 50 struct list_head rx_pool; 51 spinlock_t recv_lock; 52 atomic_t rx_cnt; 53 struct semaphore proc_sem; 54 struct task_struct *thread_tsk; 55 int exit; 56 #endif 57 int send_pid; 58 struct semaphore send_lock; 59 }; 60 61 /* ETF internal connect state*/ 62 #define ETF_STAT_NULL 0 63 #define ETF_STAT_CONNECTING 1 64 #define ETF_STAT_CONNECTED 2 65 struct xradio_etf { 66 int etf_state; 67 int is_wlan; 68 void *core_priv; 69 struct semaphore etf_lock; 70 struct xradio_adapter *adapter; 71 int seq_send; 72 int seq_recv; 73 u8 *fw_path; 74 u8 *sdd_path; 75 }; 76 77 /* ETF fw cmd defines*/ 78 #define ETF_REQ_BASE 0x0000 79 #define ETF_CNF_BASE 0x0400 80 #define ETF_IND_BASE 0x0800 81 #define ETF_MSG_STARTUP_IND_ID 0x0801 82 #define ETF_DOWNLOAD_SDD (0x20 + 22) 83 #define ETF_HWT_REQ 0x0004 84 struct etf_sdd_req { 85 u16 len; 86 u16 id; 87 u32 sdd_cmd; 88 }; 89 90 typedef enum { 91 ETF_CHANNEL_BANDWIDTH_20MHz, 92 ETF_CHANNEL_BANDWIDTH_10MHz, 93 ETF_CHANNEL_BANDWIDTH_40MHz 94 } ETF_CHANNEL_BANDWIDTH_T; 95 96 typedef enum { 97 ETF_SUB_CHANNEL_UPPER, 98 ETF_SUB_CHANNEL_LOWER 99 } ETF_SUB_CHANNEL_T; 100 101 typedef struct ETFCLI_PAR_S { 102 int g_iRateIndex; //0 103 int g_iGnModeForce; //1 104 int channel; //3 105 int mode; //4 106 int reat; //5 107 int bandwidth; //6 108 int subchannel; //7 109 } ETFCLI_PAR_T; 110 111 typedef struct CLI_PARAM_SAVE_REQ { 112 u16 Msglen; 113 u16 MsgID; 114 int result; 115 int value; 116 int index; 117 } CLI_PARAM_SAVE_T; 118 119 /* ETF driver cmd defines */ 120 #define ETF_DRIVER_CMD_START_ID (ETF_REQ_BASE + 0x03F0) 121 #define ETF_GET_API_CONTEXT_ID (ETF_REQ_BASE + 0x03F8) 122 #define ETF_GET_SDD_PARAM_ID (ETF_REQ_BASE + 0x03F9) 123 #define ETF_CONNECT_ID (ETF_REQ_BASE + 0x03FA) 124 #define ETF_DISCONNECT_ID (ETF_REQ_BASE + 0x03FB) 125 #define ETF_RECONNECT_ID (ETF_REQ_BASE + 0x03FC) 126 #define ETF_DOWNLOAD_SDD_ID (ETF_REQ_BASE + 0x03FD) 127 #define ETF_DOWNLOAD_ID (ETF_REQ_BASE + 0x03FE) 128 #define ETF_SOFT_RESET_REQ_ID (ETF_REQ_BASE + 0x03FF) 129 #define ETF_DRIVER_IND_ID (ETF_IND_BASE + 0x03FF) 130 #define ETF_GET_SDD_POWER_DEFT (ETF_REQ_BASE + 0x1FFF) 131 #define ETF_SET_CLI_PAR_DEFT (ETF_REQ_BASE + 0x03E2) 132 #define ETF_GET_CLI_PAR_DEFT (ETF_REQ_BASE + 0x03E1) 133 134 #define FLAG_GET_SDD_ALL 0x1 135 struct get_sdd_param_req { 136 u16 len; 137 u16 id; 138 u8 flags; 139 u8 ies; 140 }; 141 struct get_sdd_result { 142 u16 len; 143 u16 id; 144 u32 result; 145 u32 length; 146 /* sdd data follow */ 147 }; 148 149 struct get_cli_data_req { 150 u16 len; 151 u16 id; 152 u32 result; 153 }; 154 155 struct get_cli_data_result { 156 u16 len; 157 u16 id; 158 u32 result; 159 u32 length; 160 }; 161 162 struct etf_api_context_req { 163 u16 len; 164 u16 id; 165 u32 param; 166 }; 167 168 #define HI_SW_LABEL_MAX 128 169 struct etf_api_context_result { 170 u16 len; 171 u16 id; 172 u32 result; 173 u8 is_etf_fw_run; 174 u8 reversed[3]; 175 u32 mib_baseaddr; 176 u8 fw_label[HI_SW_LABEL_MAX]; 177 u16 fw_api_ver; 178 }; 179 180 #define ETF_CONTEXT_OFFSET (20 + HI_SW_LABEL_MAX) 181 #define HI_MAX_CONFIG_TABLES 4 182 struct etf_api_context { 183 u32 config[HI_MAX_CONFIG_TABLES]; 184 }; 185 186 /* boot State, for download file from GUI */ 187 #define BOOT_STATE_NULL 0 188 #define BOOT_WAITING_DOWNLOAD 1 189 #define BOOT_IN_PROGRESS 2 190 #define BOOT_COMPLETE 3 191 #define BOOT_SDD_COMPLETE 4 192 193 /* Driver Result code */ 194 #define BOOT_SUCCESS (0) 195 #define BOOT_ERR_DECODE (1) 196 #define BOOT_ERR_CHECKSUM (2) 197 #define BOOT_ERR_FILE_SIZE (3) 198 #define BOOT_ERR_BAD_OP (4) 199 #define ETF_ERR_CONNECTED (5) 200 #define ETF_ERR_WLAN_MODE (6) 201 #define ETF_ERR_NOT_CONNECT (7) 202 #define ETF_ERR_IO_FAILED (8) 203 #define ETF_ERR_DRIVER_HANG (9) 204 205 struct drv_resp { 206 u16 len; 207 u16 id; 208 u32 state; 209 u32 result; 210 }; 211 212 #define MSG_ID(x) ((u16)((x)&0x1fff)) 213 #define MSG_SEQ(x) (((x)>>13)&0x0007) 214 #define SEQ_MASK(x) ((x) & 0x0007) 215 216 #define DOWNLOAD_F_START 0x01 217 #define DOWNLOAD_F_END 0x02 218 #define DOWNLOAD_F_PATH_ONLY 0x04 219 struct drv_download { 220 u32 offset; 221 u32 flags; 222 /* data followed, max size is HI_MEM_BLK_BYTES */ 223 }; 224 225 #define XR829_ETF_FIRMWARE "etf_xr829.bin" 226 227 /* ETF interfaces called by WLAN core */ 228 int xradio_etf_init(void); 229 void xradio_etf_deinit(void); 230 const char *etf_get_fwpath(void); 231 const char *etf_get_sddpath(void); 232 bool etf_is_connect(void); 233 void etf_set_core(void *core_priv); 234 int xradio_etf_from_device(struct sk_buff **skb); 235 void xradio_etf_save_context(void *buf, int len); 236 int xradio_etf_suspend(void); 237 int xradio_etf_resume(void); 238 239 /* External interfaces called by etf */ 240 extern int xradio_core_init(void); 241 extern void xradio_core_deinit(void); 242 243 #endif /*XRADIO_ETF_H*/ 244