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