Merge branches 'pm-cpufreq' and 'acpi-cppc'
[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 #include "coreconfigurator.h"
12 #include "wilc_wlan_if.h"
13 #include "wilc_wlan.h"
14 #include <linux/errno.h>
15 #include <linux/slab.h>
16 #include <linux/etherdevice.h>
17 #define TAG_PARAM_OFFSET        (MAC_HDR_LEN + TIME_STAMP_LEN + \
18                                                         BEACON_INTERVAL_LEN + CAP_INFO_LEN)
19 #define ADDR1 4
20 #define ADDR2 10
21 #define ADDR3 16
22
23 /* Basic Frame Type Codes (2-bit) */
24 enum basic_frame_type {
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
30 };
31
32 /* Frame Type and Subtype Codes (6-bit) */
33 enum sub_frame_type {
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
70 };
71
72 /* Element ID  of various Information Elements */
73 enum info_element_id {
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
114 };
115
116 /* This function extracts the beacon period field from the beacon or probe   */
117 /* response frame.                                                           */
118 static inline u16 get_beacon_period(u8 *data)
119 {
120         u16 bcn_per;
121
122         bcn_per  = data[0];
123         bcn_per |= (data[1] << 8);
124
125         return bcn_per;
126 }
127
128 static inline u32 get_beacon_timestamp_lo(u8 *data)
129 {
130         u32 time_stamp = 0;
131         u32 index    = MAC_HDR_LEN;
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
141 static inline u32 get_beacon_timestamp_hi(u8 *data)
142 {
143         u32 time_stamp = 0;
144         u32 index    = (MAC_HDR_LEN + 4);
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
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.                       */
157 static inline enum sub_frame_type get_sub_type(u8 *header)
158 {
159         return ((enum sub_frame_type)(header[0] & 0xFC));
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.                       */
165 static inline u8 get_to_ds(u8 *header)
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.                       */
173 static inline u8 get_from_ds(u8 *header)
174 {
175         return ((header[1] & 0x02) >> 1);
176 }
177
178 /* This function extracts the BSSID from the incoming WLAN packet based on   */
179 /* the 'from ds' bit, and updates the MAC Address in the allocated 'data'    */
180 /* variable.                                                                 */
181 static inline void get_BSSID(u8 *data, u8 *bssid)
182 {
183         if (get_from_ds(data) == 1)
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);
190         else if (get_to_ds(data) == 1)
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);
197         else
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);
204 }
205
206 /* This function extracts the SSID from a beacon/probe response frame        */
207 static inline void get_ssid(u8 *data, u8 *ssid, u8 *p_ssid_len)
208 {
209         u8 len = 0;
210         u8 i   = 0;
211         u8 j   = 0;
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.                                                           */
233 static inline u16 get_cap_info(u8 *data)
234 {
235         u16 cap_info = 0;
236         u16 index    = MAC_HDR_LEN;
237         enum sub_frame_type st;
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.                                                                       */
254 static inline u16 get_assoc_resp_cap_info(u8 *data)
255 {
256         u16 cap_info;
257
258         cap_info  = data[0];
259         cap_info |= (data[1] << 8);
260
261         return cap_info;
262 }
263
264 /* This function extracts the association status code from the incoming       */
265 /* association response frame and returns association status code            */
266 static inline u16 get_asoc_status(u8 *data)
267 {
268         u16 asoc_status;
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                                                                                            */
278 static inline u16 get_asoc_id(u8 *data)
279 {
280         u16 asoc_id;
281
282         asoc_id  = data[4];
283         asoc_id |= (data[5] << 8);
284
285         return asoc_id;
286 }
287
288 u8 *get_tim_elm(u8 *pu8msa, u16 u16RxLen, u16 u16TagParamOffset)
289 {
290         u16 u16index;
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)) {
306                 if (pu8msa[u16index] == ITIM)
307                         return &pu8msa[u16index];
308                 u16index += (IE_HDR_LEN + pu8msa[u16index + 1]);
309         }
310
311         return NULL;
312 }
313
314 /* This function gets the current channel information from
315  * the 802.11n beacon/probe response frame */
316 u8 get_current_channel_802_11n(u8 *pu8msa, u16 u16RxLen)
317 {
318         u16 index;
319
320         index = TAG_PARAM_OFFSET;
321         while (index < (u16RxLen - FCS_LEN)) {
322                 if (pu8msa[index] == IDSPARMS)
323                         return pu8msa[index + 2];
324                 /* Increment index by length information and header */
325                 index += pu8msa[index + 1] + IE_HDR_LEN;
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
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  */
345 s32 parse_network_info(u8 *pu8MsgBuffer, tstrNetworkInfo **ppstrNetworkInfo)
346 {
347         tstrNetworkInfo *pstrNetworkInfo = NULL;
348         u8 u8MsgType = 0;
349         u8 u8MsgID = 0;
350         u16 u16MsgLen = 0;
351
352         u16 u16WidID = (u16)WID_NIL;
353         u16 u16WidLen  = 0;
354         u8  *pu8WidVal = NULL;
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");
361                 return -EFAULT;
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         {
381                 u8  *pu8msa = NULL;
382                 u16 u16RxLen = 0;
383                 u8 *pu8TimElm = NULL;
384                 u8 *pu8IEs = NULL;
385                 u16 u16IEsLen = 0;
386                 u8 u8index = 0;
387                 u32 u32Tsf_Lo;
388                 u32 u32Tsf_Hi;
389
390                 pstrNetworkInfo = kzalloc(sizeof(tstrNetworkInfo), GFP_KERNEL);
391                 if (!pstrNetworkInfo)
392                         return -ENOMEM;
393
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);
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);
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
413                 pstrNetworkInfo->u64Tsf = u32Tsf_Lo | ((u64)u32Tsf_Hi << 32);
414
415                 /* Get SSID */
416                 get_ssid(pu8msa, pstrNetworkInfo->au8ssid, &pstrNetworkInfo->u8SsidLen);
417
418                 /* Get BSSID */
419                 get_BSSID(pu8msa, pstrNetworkInfo->au8bssid);
420
421                 /*
422                  * Extract current channel information from
423                  * the beacon/probe response frame
424                  */
425                 pstrNetworkInfo->u8channel = get_current_channel_802_11n(pu8msa,
426                                                         u16RxLen + FCS_LEN);
427
428                 /* Get beacon period */
429                 u8index = MAC_HDR_LEN + TIME_STAMP_LEN;
430
431                 pstrNetworkInfo->u16BeaconPeriod = get_beacon_period(pu8msa + u8index);
432
433                 u8index += BEACON_INTERVAL_LEN + CAP_INFO_LEN;
434
435                 /* Get DTIM Period */
436                 pu8TimElm = get_tim_elm(pu8msa, u16RxLen + FCS_LEN, u8index);
437                 if (pu8TimElm != NULL)
438                         pstrNetworkInfo->u8DtimPeriod = pu8TimElm[3];
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) {
443                         pstrNetworkInfo->pu8IEs = kmemdup(pu8IEs, u16IEsLen,
444                                                           GFP_KERNEL);
445                         if (!pstrNetworkInfo->pu8IEs)
446                                 return -ENOMEM;
447                 }
448                 pstrNetworkInfo->u16IEsLen = u16IEsLen;
449
450         }
451
452         *ppstrNetworkInfo = pstrNetworkInfo;
453
454         return 0;
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  */
467 s32 DeallocateNetworkInfo(tstrNetworkInfo *pstrNetworkInfo)
468 {
469         s32 s32Error = 0;
470
471         if (pstrNetworkInfo != NULL) {
472                 if (pstrNetworkInfo->pu8IEs != NULL) {
473                         kfree(pstrNetworkInfo->pu8IEs);
474                         pstrNetworkInfo->pu8IEs = NULL;
475                 } else {
476                         s32Error = -EFAULT;
477                 }
478
479                 kfree(pstrNetworkInfo);
480                 pstrNetworkInfo = NULL;
481
482         } else {
483                 s32Error = -EFAULT;
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  */
500 s32 ParseAssocRespInfo(u8 *pu8Buffer, u32 u32BufferLen,
501                                tstrConnectRespInfo **ppstrConnectRespInfo)
502 {
503         s32 s32Error = 0;
504         tstrConnectRespInfo *pstrConnectRespInfo = NULL;
505         u16 u16AssocRespLen = 0;
506         u8 *pu8IEs = NULL;
507         u16 u16IEsLen = 0;
508
509         pstrConnectRespInfo = kzalloc(sizeof(tstrConnectRespInfo), GFP_KERNEL);
510         if (!pstrConnectRespInfo)
511                 return -ENOMEM;
512
513         /* u16AssocRespLen = pu8Buffer[0]; */
514         u16AssocRespLen = (u16)u32BufferLen;
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
530                 pstrConnectRespInfo->pu8RespIEs = kmemdup(pu8IEs, u16IEsLen, GFP_KERNEL);
531                 if (!pstrConnectRespInfo->pu8RespIEs)
532                         return -ENOMEM;
533
534                 pstrConnectRespInfo->u16RespIEsLen = u16IEsLen;
535         }
536
537         *ppstrConnectRespInfo = pstrConnectRespInfo;
538
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  */
552 s32 DeallocateAssocRespInfo(tstrConnectRespInfo *pstrConnectRespInfo)
553 {
554         s32 s32Error = 0;
555
556         if (pstrConnectRespInfo != NULL) {
557                 if (pstrConnectRespInfo->pu8RespIEs != NULL) {
558                         kfree(pstrConnectRespInfo->pu8RespIEs);
559                         pstrConnectRespInfo->pu8RespIEs = NULL;
560                 } else {
561                         s32Error = -EFAULT;
562                 }
563
564                 kfree(pstrConnectRespInfo);
565                 pstrConnectRespInfo = NULL;
566
567         } else {
568                 s32Error = -EFAULT;
569         }
570
571         return s32Error;
572 }
573
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  */
589 s32 send_config_pkt(u8 mode, struct wid *wids, u32 count, u32 drv)
590 {
591         s32 counter = 0, ret = 0;
592
593         if (mode == GET_CFG) {
594                 for (counter = 0; counter < count; counter++) {
595                         PRINT_INFO(CORECONFIG_DBG, "Sending CFG packet [%d][%d]\n", !counter,
596                                    (counter == count - 1));
597                         if (!wilc_wlan_cfg_get(!counter,
598                                                wids[counter].id,
599                                                (counter == count - 1),
600                                                drv)) {
601                                 ret = -1;
602                                 printk("[Sendconfigpkt]Get Timed out\n");
603                                 break;
604                         }
605                 }
606                 counter = 0;
607                 for (counter = 0; counter < count; counter++) {
608                         wids[counter].size = wilc_wlan_cfg_get_val(
609                                         wids[counter].id,
610                                         wids[counter].val,
611                                         wids[counter].size);
612
613                 }
614         } else if (mode == SET_CFG) {
615                 for (counter = 0; counter < count; counter++) {
616                         PRINT_D(CORECONFIG_DBG, "Sending config SET PACKET WID:%x\n", wids[counter].id);
617                         if (!wilc_wlan_cfg_set(!counter,
618                                                wids[counter].id,
619                                                wids[counter].val,
620                                                wids[counter].size,
621                                                (counter == count - 1),
622                                                drv)) {
623                                 ret = -1;
624                                 printk("[Sendconfigpkt]Set Timed out\n");
625                                 break;
626                         }
627                 }
628         }
629
630         return ret;
631 }