Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1 | |
| 2 | /*! |
| 3 | * @file coreconfigurator.c |
| 4 | * @brief |
| 5 | * @author |
| 6 | * @sa coreconfigurator.h |
| 7 | * @date 1 Mar 2012 |
| 8 | * @version 1.0 |
| 9 | */ |
| 10 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 11 | #include "coreconfigurator.h" |
Chaehyun Lim | dd32257 | 2015-09-22 22:47:43 +0900 | [diff] [blame] | 12 | #include "wilc_wlan_if.h" |
Glen Lee | 1028e5a | 2015-10-01 16:03:40 +0900 | [diff] [blame] | 13 | #include "wilc_wlan.h" |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 14 | #include <linux/errno.h> |
Chaehyun Lim | e215a87 | 2015-09-30 08:15:41 +0900 | [diff] [blame] | 15 | #include <linux/slab.h> |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 16 | #define TAG_PARAM_OFFSET (MAC_HDR_LEN + TIME_STAMP_LEN + \ |
| 17 | BEACON_INTERVAL_LEN + CAP_INFO_LEN) |
| 18 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 19 | /* Basic Frame Type Codes (2-bit) */ |
Tony Cho | 9dd2f77 | 2015-10-02 14:22:03 +0900 | [diff] [blame] | 20 | enum basic_frame_type { |
Stanislav Kholmanskikh | 13994d1 | 2015-06-10 21:57:26 +0300 | [diff] [blame] | 21 | FRAME_TYPE_CONTROL = 0x04, |
| 22 | FRAME_TYPE_DATA = 0x08, |
| 23 | FRAME_TYPE_MANAGEMENT = 0x00, |
| 24 | FRAME_TYPE_RESERVED = 0x0C, |
| 25 | FRAME_TYPE_FORCE_32BIT = 0xFFFFFFFF |
Tony Cho | 9dd2f77 | 2015-10-02 14:22:03 +0900 | [diff] [blame] | 26 | }; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 27 | |
| 28 | /* Frame Type and Subtype Codes (6-bit) */ |
Tony Cho | 9dd2f77 | 2015-10-02 14:22:03 +0900 | [diff] [blame] | 29 | enum sub_frame_type { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 30 | ASSOC_REQ = 0x00, |
| 31 | ASSOC_RSP = 0x10, |
| 32 | REASSOC_REQ = 0x20, |
| 33 | REASSOC_RSP = 0x30, |
| 34 | PROBE_REQ = 0x40, |
| 35 | PROBE_RSP = 0x50, |
| 36 | BEACON = 0x80, |
| 37 | ATIM = 0x90, |
| 38 | DISASOC = 0xA0, |
| 39 | AUTH = 0xB0, |
| 40 | DEAUTH = 0xC0, |
| 41 | ACTION = 0xD0, |
| 42 | PS_POLL = 0xA4, |
| 43 | RTS = 0xB4, |
| 44 | CTS = 0xC4, |
| 45 | ACK = 0xD4, |
| 46 | CFEND = 0xE4, |
| 47 | CFEND_ACK = 0xF4, |
| 48 | DATA = 0x08, |
| 49 | DATA_ACK = 0x18, |
| 50 | DATA_POLL = 0x28, |
| 51 | DATA_POLL_ACK = 0x38, |
| 52 | NULL_FRAME = 0x48, |
| 53 | CFACK = 0x58, |
| 54 | CFPOLL = 0x68, |
| 55 | CFPOLL_ACK = 0x78, |
| 56 | QOS_DATA = 0x88, |
| 57 | QOS_DATA_ACK = 0x98, |
| 58 | QOS_DATA_POLL = 0xA8, |
| 59 | QOS_DATA_POLL_ACK = 0xB8, |
| 60 | QOS_NULL_FRAME = 0xC8, |
| 61 | QOS_CFPOLL = 0xE8, |
| 62 | QOS_CFPOLL_ACK = 0xF8, |
| 63 | BLOCKACK_REQ = 0x84, |
| 64 | BLOCKACK = 0x94, |
| 65 | FRAME_SUBTYPE_FORCE_32BIT = 0xFFFFFFFF |
Tony Cho | 9dd2f77 | 2015-10-02 14:22:03 +0900 | [diff] [blame] | 66 | }; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 67 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 68 | /* Element ID of various Information Elements */ |
Tony Cho | 9dd2f77 | 2015-10-02 14:22:03 +0900 | [diff] [blame] | 69 | enum info_element_id { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 70 | ISSID = 0, /* Service Set Identifier */ |
| 71 | ISUPRATES = 1, /* Supported Rates */ |
| 72 | IFHPARMS = 2, /* FH parameter set */ |
| 73 | IDSPARMS = 3, /* DS parameter set */ |
| 74 | ICFPARMS = 4, /* CF parameter set */ |
| 75 | ITIM = 5, /* Traffic Information Map */ |
| 76 | IIBPARMS = 6, /* IBSS parameter set */ |
| 77 | ICOUNTRY = 7, /* Country element */ |
| 78 | IEDCAPARAMS = 12, /* EDCA parameter set */ |
| 79 | ITSPEC = 13, /* Traffic Specification */ |
| 80 | ITCLAS = 14, /* Traffic Classification */ |
| 81 | ISCHED = 15, /* Schedule */ |
| 82 | ICTEXT = 16, /* Challenge Text */ |
| 83 | IPOWERCONSTRAINT = 32, /* Power Constraint */ |
| 84 | IPOWERCAPABILITY = 33, /* Power Capability */ |
| 85 | ITPCREQUEST = 34, /* TPC Request */ |
| 86 | ITPCREPORT = 35, /* TPC Report */ |
| 87 | ISUPCHANNEL = 36, /* Supported channel list */ |
| 88 | ICHSWANNOUNC = 37, /* Channel Switch Announcement */ |
| 89 | IMEASUREMENTREQUEST = 38, /* Measurement request */ |
| 90 | IMEASUREMENTREPORT = 39, /* Measurement report */ |
| 91 | IQUIET = 40, /* Quiet element Info */ |
| 92 | IIBSSDFS = 41, /* IBSS DFS */ |
| 93 | IERPINFO = 42, /* ERP Information */ |
| 94 | ITSDELAY = 43, /* TS Delay */ |
| 95 | ITCLASPROCESS = 44, /* TCLAS Processing */ |
| 96 | IHTCAP = 45, /* HT Capabilities */ |
| 97 | IQOSCAP = 46, /* QoS Capability */ |
| 98 | IRSNELEMENT = 48, /* RSN Information Element */ |
| 99 | IEXSUPRATES = 50, /* Extended Supported Rates */ |
| 100 | IEXCHSWANNOUNC = 60, /* Extended Ch Switch Announcement*/ |
| 101 | IHTOPERATION = 61, /* HT Information */ |
| 102 | ISECCHOFF = 62, /* Secondary Channel Offeset */ |
| 103 | I2040COEX = 72, /* 20/40 Coexistence IE */ |
| 104 | I2040INTOLCHREPORT = 73, /* 20/40 Intolerant channel report*/ |
| 105 | IOBSSSCAN = 74, /* OBSS Scan parameters */ |
| 106 | IEXTCAP = 127, /* Extended capability */ |
| 107 | IWMM = 221, /* WMM parameters */ |
| 108 | IWPAELEMENT = 221, /* WPA Information Element */ |
| 109 | INFOELEM_ID_FORCE_32BIT = 0xFFFFFFFF |
Tony Cho | 9dd2f77 | 2015-10-02 14:22:03 +0900 | [diff] [blame] | 110 | }; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 111 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 112 | /* This function extracts the beacon period field from the beacon or probe */ |
| 113 | /* response frame. */ |
Chaehyun Lim | 9af382b | 2015-09-16 20:11:27 +0900 | [diff] [blame] | 114 | static inline u16 get_beacon_period(u8 *data) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 115 | { |
Amitoj Kaur Chawla | b5c84cd | 2015-10-15 13:49:47 +0530 | [diff] [blame] | 116 | u16 bcn_per; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 117 | |
| 118 | bcn_per = data[0]; |
| 119 | bcn_per |= (data[1] << 8); |
| 120 | |
| 121 | return bcn_per; |
| 122 | } |
| 123 | |
Chaehyun Lim | 9af382b | 2015-09-16 20:11:27 +0900 | [diff] [blame] | 124 | static inline u32 get_beacon_timestamp_lo(u8 *data) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 125 | { |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 126 | u32 time_stamp = 0; |
| 127 | u32 index = MAC_HDR_LEN; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 128 | |
| 129 | time_stamp |= data[index++]; |
| 130 | time_stamp |= (data[index++] << 8); |
| 131 | time_stamp |= (data[index++] << 16); |
| 132 | time_stamp |= (data[index] << 24); |
| 133 | |
| 134 | return time_stamp; |
| 135 | } |
| 136 | |
Chaehyun Lim | 9af382b | 2015-09-16 20:11:27 +0900 | [diff] [blame] | 137 | static inline u32 get_beacon_timestamp_hi(u8 *data) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 138 | { |
Chaehyun Lim | 8a54d91 | 2015-06-11 14:35:53 +0900 | [diff] [blame] | 139 | u32 time_stamp = 0; |
| 140 | u32 index = (MAC_HDR_LEN + 4); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 141 | |
| 142 | time_stamp |= data[index++]; |
| 143 | time_stamp |= (data[index++] << 8); |
| 144 | time_stamp |= (data[index++] << 16); |
| 145 | time_stamp |= (data[index] << 24); |
| 146 | |
| 147 | return time_stamp; |
| 148 | } |
| 149 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 150 | /* This function extracts the 'frame type and sub type' bits from the MAC */ |
| 151 | /* header of the input frame. */ |
| 152 | /* Returns the value in the LSB of the returned value. */ |
Tony Cho | 9dd2f77 | 2015-10-02 14:22:03 +0900 | [diff] [blame] | 153 | static inline enum sub_frame_type get_sub_type(u8 *header) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 154 | { |
Tony Cho | 9dd2f77 | 2015-10-02 14:22:03 +0900 | [diff] [blame] | 155 | return ((enum sub_frame_type)(header[0] & 0xFC)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | /* This function extracts the 'to ds' bit from the MAC header of the input */ |
| 159 | /* frame. */ |
| 160 | /* Returns the value in the LSB of the returned value. */ |
Chaehyun Lim | 9af382b | 2015-09-16 20:11:27 +0900 | [diff] [blame] | 161 | static inline u8 get_to_ds(u8 *header) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 162 | { |
| 163 | return (header[1] & 0x01); |
| 164 | } |
| 165 | |
| 166 | /* This function extracts the 'from ds' bit from the MAC header of the input */ |
| 167 | /* frame. */ |
| 168 | /* Returns the value in the LSB of the returned value. */ |
Chaehyun Lim | 9af382b | 2015-09-16 20:11:27 +0900 | [diff] [blame] | 169 | static inline u8 get_from_ds(u8 *header) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 170 | { |
| 171 | return ((header[1] & 0x02) >> 1); |
| 172 | } |
| 173 | |
Glen Lee | b57f9f3 | 2015-11-05 18:51:23 +0900 | [diff] [blame] | 174 | /* This function extracts the MAC Address in 'address1' field of the MAC */ |
| 175 | /* header and updates the MAC Address in the allocated 'addr' variable. */ |
| 176 | static inline void get_address1(u8 *pu8msa, u8 *addr) |
| 177 | { |
| 178 | memcpy(addr, pu8msa + 4, 6); |
| 179 | } |
| 180 | |
| 181 | /* This function extracts the MAC Address in 'address2' field of the MAC */ |
| 182 | /* header and updates the MAC Address in the allocated 'addr' variable. */ |
| 183 | static inline void get_address2(u8 *pu8msa, u8 *addr) |
| 184 | { |
| 185 | memcpy(addr, pu8msa + 10, 6); |
| 186 | } |
| 187 | |
| 188 | /* This function extracts the MAC Address in 'address3' field of the MAC */ |
| 189 | /* header and updates the MAC Address in the allocated 'addr' variable. */ |
| 190 | static inline void get_address3(u8 *pu8msa, u8 *addr) |
| 191 | { |
| 192 | memcpy(addr, pu8msa + 16, 6); |
| 193 | } |
| 194 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 195 | /* This function extracts the BSSID from the incoming WLAN packet based on */ |
Glen Lee | b57f9f3 | 2015-11-05 18:51:23 +0900 | [diff] [blame] | 196 | /* the 'from ds' bit, and updates the MAC Address in the allocated 'addr' */ |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 197 | /* variable. */ |
Chaehyun Lim | 9af382b | 2015-09-16 20:11:27 +0900 | [diff] [blame] | 198 | static inline void get_BSSID(u8 *data, u8 *bssid) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 199 | { |
| 200 | if (get_from_ds(data) == 1) |
Glen Lee | b57f9f3 | 2015-11-05 18:51:23 +0900 | [diff] [blame] | 201 | get_address2(data, bssid); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 202 | else if (get_to_ds(data) == 1) |
Glen Lee | b57f9f3 | 2015-11-05 18:51:23 +0900 | [diff] [blame] | 203 | get_address1(data, bssid); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 204 | else |
Glen Lee | b57f9f3 | 2015-11-05 18:51:23 +0900 | [diff] [blame] | 205 | get_address3(data, bssid); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 206 | } |
| 207 | |
| 208 | /* This function extracts the SSID from a beacon/probe response frame */ |
Chaehyun Lim | 9af382b | 2015-09-16 20:11:27 +0900 | [diff] [blame] | 209 | static inline void get_ssid(u8 *data, u8 *ssid, u8 *p_ssid_len) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 210 | { |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 211 | u8 len = 0; |
| 212 | u8 i = 0; |
| 213 | u8 j = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 214 | |
| 215 | len = data[MAC_HDR_LEN + TIME_STAMP_LEN + BEACON_INTERVAL_LEN + |
| 216 | CAP_INFO_LEN + 1]; |
| 217 | j = MAC_HDR_LEN + TIME_STAMP_LEN + BEACON_INTERVAL_LEN + |
| 218 | CAP_INFO_LEN + 2; |
| 219 | |
| 220 | /* If the SSID length field is set wrongly to a value greater than the */ |
| 221 | /* allowed maximum SSID length limit, reset the length to 0 */ |
| 222 | if (len >= MAX_SSID_LEN) |
| 223 | len = 0; |
| 224 | |
| 225 | for (i = 0; i < len; i++, j++) |
| 226 | ssid[i] = data[j]; |
| 227 | |
| 228 | ssid[len] = '\0'; |
| 229 | |
| 230 | *p_ssid_len = len; |
| 231 | } |
| 232 | |
| 233 | /* This function extracts the capability info field from the beacon or probe */ |
| 234 | /* response frame. */ |
Chaehyun Lim | 9af382b | 2015-09-16 20:11:27 +0900 | [diff] [blame] | 235 | static inline u16 get_cap_info(u8 *data) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 236 | { |
Chaehyun Lim | d85f532 | 2015-06-11 14:35:54 +0900 | [diff] [blame] | 237 | u16 cap_info = 0; |
| 238 | u16 index = MAC_HDR_LEN; |
Tony Cho | 9dd2f77 | 2015-10-02 14:22:03 +0900 | [diff] [blame] | 239 | enum sub_frame_type st; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 240 | |
| 241 | st = get_sub_type(data); |
| 242 | |
| 243 | /* Location of the Capability field is different for Beacon and */ |
| 244 | /* Association frames. */ |
| 245 | if ((st == BEACON) || (st == PROBE_RSP)) |
| 246 | index += TIME_STAMP_LEN + BEACON_INTERVAL_LEN; |
| 247 | |
| 248 | cap_info = data[index]; |
| 249 | cap_info |= (data[index + 1] << 8); |
| 250 | |
| 251 | return cap_info; |
| 252 | } |
| 253 | |
| 254 | /* This function extracts the capability info field from the Association */ |
| 255 | /* response frame. */ |
Chaehyun Lim | 9af382b | 2015-09-16 20:11:27 +0900 | [diff] [blame] | 256 | static inline u16 get_assoc_resp_cap_info(u8 *data) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 257 | { |
Amitoj Kaur Chawla | b5c84cd | 2015-10-15 13:49:47 +0530 | [diff] [blame] | 258 | u16 cap_info; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 259 | |
| 260 | cap_info = data[0]; |
| 261 | cap_info |= (data[1] << 8); |
| 262 | |
| 263 | return cap_info; |
| 264 | } |
| 265 | |
Aybuke Ozdemir | 960819a | 2015-10-06 22:14:02 +0300 | [diff] [blame] | 266 | /* This function extracts the association status code from the incoming */ |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 267 | /* association response frame and returns association status code */ |
Chaehyun Lim | 9af382b | 2015-09-16 20:11:27 +0900 | [diff] [blame] | 268 | static inline u16 get_asoc_status(u8 *data) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 269 | { |
Amitoj Kaur Chawla | b5c84cd | 2015-10-15 13:49:47 +0530 | [diff] [blame] | 270 | u16 asoc_status; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 271 | |
| 272 | asoc_status = data[3]; |
| 273 | asoc_status = (asoc_status << 8) | data[2]; |
| 274 | |
| 275 | return asoc_status; |
| 276 | } |
| 277 | |
| 278 | /* This function extracts association ID from the incoming association */ |
| 279 | /* response frame */ |
Chaehyun Lim | 9af382b | 2015-09-16 20:11:27 +0900 | [diff] [blame] | 280 | static inline u16 get_asoc_id(u8 *data) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 281 | { |
Amitoj Kaur Chawla | b5c84cd | 2015-10-15 13:49:47 +0530 | [diff] [blame] | 282 | u16 asoc_id; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 283 | |
| 284 | asoc_id = data[4]; |
| 285 | asoc_id |= (data[5] << 8); |
| 286 | |
| 287 | return asoc_id; |
| 288 | } |
| 289 | |
Arnd Bergmann | 1608c40 | 2015-11-16 15:04:53 +0100 | [diff] [blame] | 290 | static u8 *get_tim_elm(u8 *pu8msa, u16 u16RxLen, u16 u16TagParamOffset) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 291 | { |
Amitoj Kaur Chawla | b5c84cd | 2015-10-15 13:49:47 +0530 | [diff] [blame] | 292 | u16 u16index; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 293 | |
| 294 | /*************************************************************************/ |
| 295 | /* Beacon Frame - Frame Body */ |
| 296 | /* --------------------------------------------------------------------- */ |
| 297 | /* |Timestamp |BeaconInt |CapInfo |SSID |SupRates |DSParSet |TIM elm | */ |
| 298 | /* --------------------------------------------------------------------- */ |
| 299 | /* |8 |2 |2 |2-34 |3-10 |3 |4-256 | */ |
| 300 | /* --------------------------------------------------------------------- */ |
| 301 | /* */ |
| 302 | /*************************************************************************/ |
| 303 | |
| 304 | u16index = u16TagParamOffset; |
| 305 | |
| 306 | /* Search for the TIM Element Field and return if the element is found */ |
| 307 | while (u16index < (u16RxLen - FCS_LEN)) { |
Chandra S Gorentla | 78174ad | 2015-08-08 17:41:36 +0530 | [diff] [blame] | 308 | if (pu8msa[u16index] == ITIM) |
Stanislav Kholmanskikh | cea3b20 | 2015-06-10 21:57:25 +0300 | [diff] [blame] | 309 | return &pu8msa[u16index]; |
Aybuke Ozdemir | 86e4180 | 2015-10-17 15:25:34 +0300 | [diff] [blame] | 310 | u16index += (IE_HDR_LEN + pu8msa[u16index + 1]); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 311 | } |
| 312 | |
Ronit Halder | 0e04f3f | 2015-09-14 11:03:34 +0530 | [diff] [blame] | 313 | return NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 314 | } |
| 315 | |
| 316 | /* This function gets the current channel information from |
| 317 | * the 802.11n beacon/probe response frame */ |
Arnd Bergmann | 1608c40 | 2015-11-16 15:04:53 +0100 | [diff] [blame] | 318 | static u8 get_current_channel_802_11n(u8 *pu8msa, u16 u16RxLen) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 319 | { |
Chaehyun Lim | d85f532 | 2015-06-11 14:35:54 +0900 | [diff] [blame] | 320 | u16 index; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 321 | |
| 322 | index = TAG_PARAM_OFFSET; |
| 323 | while (index < (u16RxLen - FCS_LEN)) { |
| 324 | if (pu8msa[index] == IDSPARMS) |
Stanislav Kholmanskikh | cea3b20 | 2015-06-10 21:57:25 +0300 | [diff] [blame] | 325 | return pu8msa[index + 2]; |
Aybuke Ozdemir | 86e4180 | 2015-10-17 15:25:34 +0300 | [diff] [blame] | 326 | /* Increment index by length information and header */ |
| 327 | index += pu8msa[index + 1] + IE_HDR_LEN; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 328 | } |
| 329 | |
| 330 | /* Return current channel information from the MIB, if beacon/probe */ |
| 331 | /* response frame does not contain the DS parameter set IE */ |
| 332 | /* return (mget_CurrentChannel() + 1); */ |
| 333 | return 0; /* no MIB here */ |
| 334 | } |
| 335 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 336 | /** |
| 337 | * @brief parses the received 'N' message |
| 338 | * @details |
| 339 | * @param[in] pu8MsgBuffer The message to be parsed |
| 340 | * @param[out] ppstrNetworkInfo pointer to pointer to the structure containing the parsed Network Info |
| 341 | * @return Error code indicating success/failure |
| 342 | * @note |
| 343 | * @author mabubakr |
| 344 | * @date 1 Mar 2012 |
| 345 | * @version 1.0 |
| 346 | */ |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 347 | s32 wilc_parse_network_info(u8 *pu8MsgBuffer, tstrNetworkInfo **ppstrNetworkInfo) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 348 | { |
Greg Kroah-Hartman | b1413b6 | 2015-06-02 14:11:12 +0900 | [diff] [blame] | 349 | tstrNetworkInfo *pstrNetworkInfo = NULL; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 350 | u8 u8MsgType = 0; |
| 351 | u8 u8MsgID = 0; |
Chaehyun Lim | d85f532 | 2015-06-11 14:35:54 +0900 | [diff] [blame] | 352 | u16 u16MsgLen = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 353 | |
Chaehyun Lim | d85f532 | 2015-06-11 14:35:54 +0900 | [diff] [blame] | 354 | u16 u16WidID = (u16)WID_NIL; |
| 355 | u16 u16WidLen = 0; |
Ronit Halder | 0e04f3f | 2015-09-14 11:03:34 +0530 | [diff] [blame] | 356 | u8 *pu8WidVal = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 357 | |
| 358 | u8MsgType = pu8MsgBuffer[0]; |
| 359 | |
| 360 | /* Check whether the received message type is 'N' */ |
| 361 | if ('N' != u8MsgType) { |
| 362 | PRINT_ER("Received Message format incorrect.\n"); |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 363 | return -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 364 | } |
| 365 | |
| 366 | /* Extract message ID */ |
| 367 | u8MsgID = pu8MsgBuffer[1]; |
| 368 | |
| 369 | /* Extract message Length */ |
| 370 | u16MsgLen = MAKE_WORD16(pu8MsgBuffer[2], pu8MsgBuffer[3]); |
| 371 | |
| 372 | /* Extract WID ID */ |
| 373 | u16WidID = MAKE_WORD16(pu8MsgBuffer[4], pu8MsgBuffer[5]); |
| 374 | |
| 375 | /* Extract WID Length */ |
| 376 | u16WidLen = MAKE_WORD16(pu8MsgBuffer[6], pu8MsgBuffer[7]); |
| 377 | |
| 378 | /* Assign a pointer to the WID value */ |
| 379 | pu8WidVal = &pu8MsgBuffer[8]; |
| 380 | |
| 381 | /* parse the WID value of the WID "WID_NEWORK_INFO" */ |
| 382 | { |
Ronit Halder | 0e04f3f | 2015-09-14 11:03:34 +0530 | [diff] [blame] | 383 | u8 *pu8msa = NULL; |
Chaehyun Lim | d85f532 | 2015-06-11 14:35:54 +0900 | [diff] [blame] | 384 | u16 u16RxLen = 0; |
Ronit Halder | 0e04f3f | 2015-09-14 11:03:34 +0530 | [diff] [blame] | 385 | u8 *pu8TimElm = NULL; |
| 386 | u8 *pu8IEs = NULL; |
Chaehyun Lim | d85f532 | 2015-06-11 14:35:54 +0900 | [diff] [blame] | 387 | u16 u16IEsLen = 0; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 388 | u8 u8index = 0; |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 389 | u32 u32Tsf_Lo; |
| 390 | u32 u32Tsf_Hi; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 391 | |
Chaehyun Lim | ef15441 | 2015-09-22 22:47:39 +0900 | [diff] [blame] | 392 | pstrNetworkInfo = kzalloc(sizeof(tstrNetworkInfo), GFP_KERNEL); |
Chaehyun Lim | a78d9a3 | 2015-08-17 11:05:15 +0900 | [diff] [blame] | 393 | if (!pstrNetworkInfo) |
| 394 | return -ENOMEM; |
| 395 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 396 | pstrNetworkInfo->s8rssi = pu8WidVal[0]; |
| 397 | |
| 398 | /* Assign a pointer to msa "Mac Header Start Address" */ |
| 399 | pu8msa = &pu8WidVal[1]; |
| 400 | |
| 401 | u16RxLen = u16WidLen - 1; |
| 402 | |
| 403 | /* parse msa*/ |
| 404 | |
| 405 | /* Get the cap_info */ |
| 406 | pstrNetworkInfo->u16CapInfo = get_cap_info(pu8msa); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 407 | /* Get time-stamp [Low only 32 bit] */ |
| 408 | pstrNetworkInfo->u32Tsf = get_beacon_timestamp_lo(pu8msa); |
| 409 | PRINT_D(CORECONFIG_DBG, "TSF :%x\n", pstrNetworkInfo->u32Tsf); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 410 | |
| 411 | /* Get full time-stamp [Low and High 64 bit] */ |
| 412 | u32Tsf_Lo = get_beacon_timestamp_lo(pu8msa); |
| 413 | u32Tsf_Hi = get_beacon_timestamp_hi(pu8msa); |
| 414 | |
Chaehyun Lim | 57b298f | 2015-06-11 14:35:56 +0900 | [diff] [blame] | 415 | pstrNetworkInfo->u64Tsf = u32Tsf_Lo | ((u64)u32Tsf_Hi << 32); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 416 | |
| 417 | /* Get SSID */ |
Aybuke Ozdemir | 09c02cb | 2015-10-17 15:25:35 +0300 | [diff] [blame] | 418 | get_ssid(pu8msa, pstrNetworkInfo->au8ssid, &pstrNetworkInfo->u8SsidLen); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 419 | |
| 420 | /* Get BSSID */ |
| 421 | get_BSSID(pu8msa, pstrNetworkInfo->au8bssid); |
| 422 | |
Shivani Bhardwaj | ce08189 | 2015-10-27 22:58:06 +0530 | [diff] [blame] | 423 | /* |
Shivani Bhardwaj | a66907d | 2015-10-26 20:21:05 +0530 | [diff] [blame] | 424 | * Extract current channel information from |
Shivani Bhardwaj | ce08189 | 2015-10-27 22:58:06 +0530 | [diff] [blame] | 425 | * the beacon/probe response frame |
Shivani Bhardwaj | a66907d | 2015-10-26 20:21:05 +0530 | [diff] [blame] | 426 | */ |
| 427 | pstrNetworkInfo->u8channel = get_current_channel_802_11n(pu8msa, |
Shivani Bhardwaj | b5c4e4e | 2015-10-26 20:21:26 +0530 | [diff] [blame] | 428 | u16RxLen + FCS_LEN); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 429 | |
| 430 | /* Get beacon period */ |
Shivani Bhardwaj | b5c4e4e | 2015-10-26 20:21:26 +0530 | [diff] [blame] | 431 | u8index = MAC_HDR_LEN + TIME_STAMP_LEN; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 432 | |
| 433 | pstrNetworkInfo->u16BeaconPeriod = get_beacon_period(pu8msa + u8index); |
| 434 | |
| 435 | u8index += BEACON_INTERVAL_LEN + CAP_INFO_LEN; |
| 436 | |
| 437 | /* Get DTIM Period */ |
Shivani Bhardwaj | b5c4e4e | 2015-10-26 20:21:26 +0530 | [diff] [blame] | 438 | pu8TimElm = get_tim_elm(pu8msa, u16RxLen + FCS_LEN, u8index); |
Bogicevic Sasa | f6e0e2a | 2015-11-18 12:45:05 +0100 | [diff] [blame] | 439 | if (pu8TimElm) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 440 | pstrNetworkInfo->u8DtimPeriod = pu8TimElm[3]; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 441 | pu8IEs = &pu8msa[MAC_HDR_LEN + TIME_STAMP_LEN + BEACON_INTERVAL_LEN + CAP_INFO_LEN]; |
| 442 | u16IEsLen = u16RxLen - (MAC_HDR_LEN + TIME_STAMP_LEN + BEACON_INTERVAL_LEN + CAP_INFO_LEN); |
| 443 | |
| 444 | if (u16IEsLen > 0) { |
Chaehyun Lim | 02cf299 | 2015-09-22 22:47:40 +0900 | [diff] [blame] | 445 | pstrNetworkInfo->pu8IEs = kmemdup(pu8IEs, u16IEsLen, |
| 446 | GFP_KERNEL); |
Chaehyun Lim | a78d9a3 | 2015-08-17 11:05:15 +0900 | [diff] [blame] | 447 | if (!pstrNetworkInfo->pu8IEs) |
| 448 | return -ENOMEM; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 449 | } |
| 450 | pstrNetworkInfo->u16IEsLen = u16IEsLen; |
| 451 | |
| 452 | } |
| 453 | |
| 454 | *ppstrNetworkInfo = pstrNetworkInfo; |
| 455 | |
Chaehyun Lim | 74a443e | 2015-09-22 22:47:45 +0900 | [diff] [blame] | 456 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 457 | } |
| 458 | |
| 459 | /** |
| 460 | * @brief Deallocates the parsed Network Info |
| 461 | * @details |
| 462 | * @param[in] pstrNetworkInfo Network Info to be deallocated |
| 463 | * @return Error code indicating success/failure |
| 464 | * @note |
| 465 | * @author mabubakr |
| 466 | * @date 1 Mar 2012 |
| 467 | * @version 1.0 |
| 468 | */ |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 469 | s32 wilc_dealloc_network_info(tstrNetworkInfo *pstrNetworkInfo) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 470 | { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 471 | s32 s32Error = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 472 | |
Bogicevic Sasa | f6e0e2a | 2015-11-18 12:45:05 +0100 | [diff] [blame] | 473 | if (pstrNetworkInfo) { |
| 474 | if (pstrNetworkInfo->pu8IEs) { |
Chaehyun Lim | 49188af | 2015-08-11 10:32:41 +0900 | [diff] [blame] | 475 | kfree(pstrNetworkInfo->pu8IEs); |
Greg Kroah-Hartman | b1413b6 | 2015-06-02 14:11:12 +0900 | [diff] [blame] | 476 | pstrNetworkInfo->pu8IEs = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 477 | } else { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 478 | s32Error = -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 479 | } |
| 480 | |
Chaehyun Lim | 49188af | 2015-08-11 10:32:41 +0900 | [diff] [blame] | 481 | kfree(pstrNetworkInfo); |
Greg Kroah-Hartman | b1413b6 | 2015-06-02 14:11:12 +0900 | [diff] [blame] | 482 | pstrNetworkInfo = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 483 | |
| 484 | } else { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 485 | s32Error = -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 486 | } |
| 487 | |
| 488 | return s32Error; |
| 489 | } |
| 490 | |
| 491 | /** |
| 492 | * @brief parses the received Association Response frame |
| 493 | * @details |
| 494 | * @param[in] pu8Buffer The Association Response frame to be parsed |
| 495 | * @param[out] ppstrConnectRespInfo pointer to pointer to the structure containing the parsed Association Response Info |
| 496 | * @return Error code indicating success/failure |
| 497 | * @note |
| 498 | * @author mabubakr |
| 499 | * @date 2 Apr 2012 |
| 500 | * @version 1.0 |
| 501 | */ |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 502 | s32 wilc_parse_assoc_resp_info(u8 *pu8Buffer, u32 u32BufferLen, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 503 | tstrConnectRespInfo **ppstrConnectRespInfo) |
| 504 | { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 505 | s32 s32Error = 0; |
Greg Kroah-Hartman | b1413b6 | 2015-06-02 14:11:12 +0900 | [diff] [blame] | 506 | tstrConnectRespInfo *pstrConnectRespInfo = NULL; |
Chaehyun Lim | d85f532 | 2015-06-11 14:35:54 +0900 | [diff] [blame] | 507 | u16 u16AssocRespLen = 0; |
Ronit Halder | 0e04f3f | 2015-09-14 11:03:34 +0530 | [diff] [blame] | 508 | u8 *pu8IEs = NULL; |
Chaehyun Lim | d85f532 | 2015-06-11 14:35:54 +0900 | [diff] [blame] | 509 | u16 u16IEsLen = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 510 | |
Chaehyun Lim | ef15441 | 2015-09-22 22:47:39 +0900 | [diff] [blame] | 511 | pstrConnectRespInfo = kzalloc(sizeof(tstrConnectRespInfo), GFP_KERNEL); |
Chaehyun Lim | a78d9a3 | 2015-08-17 11:05:15 +0900 | [diff] [blame] | 512 | if (!pstrConnectRespInfo) |
| 513 | return -ENOMEM; |
| 514 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 515 | /* u16AssocRespLen = pu8Buffer[0]; */ |
Chaehyun Lim | d85f532 | 2015-06-11 14:35:54 +0900 | [diff] [blame] | 516 | u16AssocRespLen = (u16)u32BufferLen; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 517 | |
| 518 | /* get the status code */ |
| 519 | pstrConnectRespInfo->u16ConnectStatus = get_asoc_status(pu8Buffer); |
| 520 | if (pstrConnectRespInfo->u16ConnectStatus == SUCCESSFUL_STATUSCODE) { |
| 521 | |
| 522 | /* get the capability */ |
| 523 | pstrConnectRespInfo->u16capability = get_assoc_resp_cap_info(pu8Buffer); |
| 524 | |
| 525 | /* get the Association ID */ |
| 526 | pstrConnectRespInfo->u16AssocID = get_asoc_id(pu8Buffer); |
| 527 | |
| 528 | /* get the Information Elements */ |
| 529 | pu8IEs = &pu8Buffer[CAP_INFO_LEN + STATUS_CODE_LEN + AID_LEN]; |
| 530 | u16IEsLen = u16AssocRespLen - (CAP_INFO_LEN + STATUS_CODE_LEN + AID_LEN); |
| 531 | |
Chaehyun Lim | 02cf299 | 2015-09-22 22:47:40 +0900 | [diff] [blame] | 532 | pstrConnectRespInfo->pu8RespIEs = kmemdup(pu8IEs, u16IEsLen, GFP_KERNEL); |
Chaehyun Lim | a78d9a3 | 2015-08-17 11:05:15 +0900 | [diff] [blame] | 533 | if (!pstrConnectRespInfo->pu8RespIEs) |
| 534 | return -ENOMEM; |
| 535 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 536 | pstrConnectRespInfo->u16RespIEsLen = u16IEsLen; |
| 537 | } |
| 538 | |
| 539 | *ppstrConnectRespInfo = pstrConnectRespInfo; |
| 540 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 541 | return s32Error; |
| 542 | } |
| 543 | |
| 544 | /** |
| 545 | * @brief Deallocates the parsed Association Response Info |
| 546 | * @details |
| 547 | * @param[in] pstrNetworkInfo Network Info to be deallocated |
| 548 | * @return Error code indicating success/failure |
| 549 | * @note |
| 550 | * @author mabubakr |
| 551 | * @date 2 Apr 2012 |
| 552 | * @version 1.0 |
| 553 | */ |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 554 | s32 wilc_dealloc_assoc_resp_info(tstrConnectRespInfo *pstrConnectRespInfo) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 555 | { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 556 | s32 s32Error = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 557 | |
Bogicevic Sasa | f6e0e2a | 2015-11-18 12:45:05 +0100 | [diff] [blame] | 558 | if (pstrConnectRespInfo) { |
| 559 | if (pstrConnectRespInfo->pu8RespIEs) { |
Chaehyun Lim | 49188af | 2015-08-11 10:32:41 +0900 | [diff] [blame] | 560 | kfree(pstrConnectRespInfo->pu8RespIEs); |
Greg Kroah-Hartman | b1413b6 | 2015-06-02 14:11:12 +0900 | [diff] [blame] | 561 | pstrConnectRespInfo->pu8RespIEs = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 562 | } else { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 563 | s32Error = -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 564 | } |
| 565 | |
Chaehyun Lim | 49188af | 2015-08-11 10:32:41 +0900 | [diff] [blame] | 566 | kfree(pstrConnectRespInfo); |
Greg Kroah-Hartman | b1413b6 | 2015-06-02 14:11:12 +0900 | [diff] [blame] | 567 | pstrConnectRespInfo = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 568 | |
| 569 | } else { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 570 | s32Error = -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 571 | } |
| 572 | |
| 573 | return s32Error; |
| 574 | } |
| 575 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 576 | /** |
| 577 | * @brief sends certain Configuration Packet based on the input WIDs pstrWIDs |
| 578 | * using driver config layer |
| 579 | * |
| 580 | * @details |
| 581 | * @param[in] pstrWIDs WIDs to be sent in the configuration packet |
| 582 | * @param[in] u32WIDsCount number of WIDs to be sent in the configuration packet |
| 583 | * @param[out] pu8RxResp The received Packet Response |
| 584 | * @param[out] ps32RxRespLen Length of the received Packet Response |
| 585 | * @return Error code indicating success/failure |
| 586 | * @note |
| 587 | * @author mabubakr |
| 588 | * @date 1 Mar 2012 |
| 589 | * @version 1.0 |
| 590 | */ |
Glen Lee | ec62e6d | 2015-11-18 15:11:33 +0900 | [diff] [blame] | 591 | s32 wilc_send_config_pkt(struct wilc *wilc, u8 mode, struct wid *wids, |
| 592 | u32 count, u32 drv) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 593 | { |
Chaehyun Lim | fb4ec9c | 2015-06-11 14:35:59 +0900 | [diff] [blame] | 594 | s32 counter = 0, ret = 0; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 595 | |
Tony Cho | 684125a | 2015-10-12 16:55:40 +0900 | [diff] [blame] | 596 | if (mode == GET_CFG) { |
| 597 | for (counter = 0; counter < count; counter++) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 598 | PRINT_INFO(CORECONFIG_DBG, "Sending CFG packet [%d][%d]\n", !counter, |
Tony Cho | 684125a | 2015-10-12 16:55:40 +0900 | [diff] [blame] | 599 | (counter == count - 1)); |
Glen Lee | d40c99c | 2015-11-18 15:11:35 +0900 | [diff] [blame] | 600 | if (!wilc_wlan_cfg_get(wilc, !counter, |
Leo Kim | daaf16b | 2015-10-12 16:55:44 +0900 | [diff] [blame] | 601 | wids[counter].id, |
Tony Cho | 684125a | 2015-10-12 16:55:40 +0900 | [diff] [blame] | 602 | (counter == count - 1), |
| 603 | drv)) { |
Glen Lee | c2ba8b2 | 2015-11-20 16:56:32 +0900 | [diff] [blame] | 604 | ret = -ETIMEDOUT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 605 | printk("[Sendconfigpkt]Get Timed out\n"); |
| 606 | break; |
| 607 | } |
| 608 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 609 | counter = 0; |
Tony Cho | 684125a | 2015-10-12 16:55:40 +0900 | [diff] [blame] | 610 | for (counter = 0; counter < count; counter++) { |
Leo Kim | 2fd3e44 | 2015-10-12 16:55:45 +0900 | [diff] [blame] | 611 | wids[counter].size = wilc_wlan_cfg_get_val( |
Leo Kim | daaf16b | 2015-10-12 16:55:44 +0900 | [diff] [blame] | 612 | wids[counter].id, |
Leo Kim | 900bb4a | 2015-10-12 16:55:46 +0900 | [diff] [blame] | 613 | wids[counter].val, |
Leo Kim | 2fd3e44 | 2015-10-12 16:55:45 +0900 | [diff] [blame] | 614 | wids[counter].size); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 615 | } |
Tony Cho | 684125a | 2015-10-12 16:55:40 +0900 | [diff] [blame] | 616 | } else if (mode == SET_CFG) { |
| 617 | for (counter = 0; counter < count; counter++) { |
Leo Kim | daaf16b | 2015-10-12 16:55:44 +0900 | [diff] [blame] | 618 | PRINT_D(CORECONFIG_DBG, "Sending config SET PACKET WID:%x\n", wids[counter].id); |
Glen Lee | 89758e1 | 2015-11-18 15:11:34 +0900 | [diff] [blame] | 619 | if (!wilc_wlan_cfg_set(wilc, !counter, |
Leo Kim | daaf16b | 2015-10-12 16:55:44 +0900 | [diff] [blame] | 620 | wids[counter].id, |
Leo Kim | 900bb4a | 2015-10-12 16:55:46 +0900 | [diff] [blame] | 621 | wids[counter].val, |
Leo Kim | 2fd3e44 | 2015-10-12 16:55:45 +0900 | [diff] [blame] | 622 | wids[counter].size, |
Tony Cho | 684125a | 2015-10-12 16:55:40 +0900 | [diff] [blame] | 623 | (counter == count - 1), |
| 624 | drv)) { |
Glen Lee | c2ba8b2 | 2015-11-20 16:56:32 +0900 | [diff] [blame] | 625 | ret = -ETIMEDOUT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 626 | printk("[Sendconfigpkt]Set Timed out\n"); |
| 627 | break; |
| 628 | } |
| 629 | } |
| 630 | } |
| 631 | |
| 632 | return ret; |
| 633 | } |