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