linux/drivers/staging/wilc1000/host_interface.c
<<
>>
Prefs
   1#include "host_interface.h"
   2#include "coreconfigurator.h"
   3
   4extern s32 TransportInit(void);
   5extern s32 TransportDeInit(void);
   6extern u8 connecting;
   7
   8#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
   9extern struct timer_list hDuringIpTimer;
  10#endif
  11
  12/*BugID_5137*/
  13extern u8 g_wilc_initialized;
  14/*****************************************************************************/
  15/*                                                              Macros                                       */
  16/*****************************************************************************/
  17
  18/* Message types of the Host IF Message Queue*/
  19#define HOST_IF_MSG_SCAN                        0
  20#define HOST_IF_MSG_CONNECT                     1
  21#define HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO        2
  22#define HOST_IF_MSG_KEY                         3
  23#define HOST_IF_MSG_RCVD_NTWRK_INFO             4
  24#define HOST_IF_MSG_RCVD_SCAN_COMPLETE          5
  25#define HOST_IF_MSG_CFG_PARAMS                  6
  26#define HOST_IF_MSG_SET_CHANNEL                 7
  27#define HOST_IF_MSG_DISCONNECT                  8
  28#define HOST_IF_MSG_GET_RSSI                    9
  29#define HOST_IF_MSG_GET_CHNL                    10
  30#define HOST_IF_MSG_ADD_BEACON                  11
  31#define HOST_IF_MSG_DEL_BEACON                  12
  32#define HOST_IF_MSG_ADD_STATION                 13
  33#define HOST_IF_MSG_DEL_STATION                 14
  34#define HOST_IF_MSG_EDIT_STATION                15
  35#define HOST_IF_MSG_SCAN_TIMER_FIRED            16
  36#define HOST_IF_MSG_CONNECT_TIMER_FIRED         17
  37#define HOST_IF_MSG_POWER_MGMT                  18
  38#define HOST_IF_MSG_GET_INACTIVETIME            19
  39#define HOST_IF_MSG_REMAIN_ON_CHAN              20
  40#define HOST_IF_MSG_REGISTER_FRAME              21
  41#define HOST_IF_MSG_LISTEN_TIMER_FIRED          22
  42#define HOST_IF_MSG_GET_LINKSPEED               23
  43#define HOST_IF_MSG_SET_WFIDRV_HANDLER          24
  44#define HOST_IF_MSG_SET_MAC_ADDRESS             25
  45#define HOST_IF_MSG_GET_MAC_ADDRESS             26
  46#define HOST_IF_MSG_SET_OPERATION_MODE          27
  47#define HOST_IF_MSG_SET_IPADDRESS               28
  48#define HOST_IF_MSG_GET_IPADDRESS               29
  49#define HOST_IF_MSG_FLUSH_CONNECT               30
  50#define HOST_IF_MSG_GET_STATISTICS              31
  51#define HOST_IF_MSG_SET_MULTICAST_FILTER        32
  52#define HOST_IF_MSG_ADD_BA_SESSION              33
  53#define HOST_IF_MSG_DEL_BA_SESSION              34
  54#define HOST_IF_MSG_Q_IDLE                      35
  55#define HOST_IF_MSG_DEL_ALL_STA                 36
  56#define HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS      34
  57#define HOST_IF_MSG_EXIT                        100
  58
  59#define HOST_IF_SCAN_TIMEOUT                    4000
  60#define HOST_IF_CONNECT_TIMEOUT                 9500
  61
  62#define BA_SESSION_DEFAULT_BUFFER_SIZE          16
  63#define BA_SESSION_DEFAULT_TIMEOUT              1000
  64#define BLOCK_ACK_REQ_SIZE                      0x14
  65/*****************************************************************************/
  66/*                                                              Type Definitions                                                         */
  67/*****************************************************************************/
  68
  69/*!
  70 *  @struct             tstrHostIFCfgParamAttr
  71 *  @brief              Structure to hold Host IF CFG Params Attributes
  72 *  @details
  73 *  @todo
  74 *  @sa
  75 *  @author             Mai Daftedar
  76 *  @date               02 April 2012
  77 *  @version            1.0
  78 */
  79typedef struct _tstrHostIFCfgParamAttr {
  80        tstrCfgParamVal pstrCfgParamVal;
  81
  82} tstrHostIFCfgParamAttr;
  83
  84/*!
  85 *  @struct             tstrHostIFwpaAttr
  86 *  @brief              Structure to hold Host IF Scan Attributes
  87 *  @details
  88 *  @todo
  89 *  @sa
  90 *  @author             Mai Daftedar
  91 *  @date               25 March 2012
  92 *  @version            1.0
  93 */
  94typedef struct _tstrHostIFwpaAttr {
  95        u8 *pu8key;
  96        const u8 *pu8macaddr;
  97        u8 *pu8seq;
  98        u8 u8seqlen;
  99        u8 u8keyidx;
 100        u8 u8Keylen;
 101        u8 u8Ciphermode;
 102} tstrHostIFwpaAttr;
 103
 104
 105/*!
 106 *  @struct             tstrHostIFwepAttr
 107 *  @brief              Structure to hold Host IF Scan Attributes
 108 *  @details
 109 *  @todo
 110 *  @sa
 111 *  @author             Mai Daftedar
 112 *  @date               25 March 2012
 113 *  @version            1.0
 114 */
 115typedef struct _tstrHostIFwepAttr {
 116        u8 *pu8WepKey;
 117        u8 u8WepKeylen;
 118        u8 u8Wepidx;
 119        u8 u8mode;
 120        AUTHTYPE_T tenuAuth_type;
 121
 122} tstrHostIFwepAttr;
 123
 124/*!
 125 *  @struct             tuniHostIFkeyAttr
 126 *  @brief              Structure to hold Host IF Scan Attributes
 127 *  @details
 128 *  @todo
 129 *  @sa
 130 *  @author             Mai Daftedar
 131 *  @date               25 March 2012
 132 *  @version            1.0
 133 */
 134typedef union _tuniHostIFkeyAttr {
 135        tstrHostIFwepAttr strHostIFwepAttr;
 136        tstrHostIFwpaAttr strHostIFwpaAttr;
 137        tstrHostIFpmkidAttr strHostIFpmkidAttr;
 138} tuniHostIFkeyAttr;
 139
 140/*!
 141 *  @struct             tstrHostIFkeyAttr
 142 *  @brief              Structure to hold Host IF Scan Attributes
 143 *  @details
 144 *  @todo
 145 *  @sa
 146 *  @author             Mai Daftedar
 147 *  @date               25 March 2012
 148 *  @version            1.0
 149 */
 150typedef struct _tstrHostIFkeyAttr {
 151        tenuKeyType enuKeyType;
 152        u8 u8KeyAction;
 153        tuniHostIFkeyAttr uniHostIFkeyAttr;
 154} tstrHostIFkeyAttr;
 155
 156
 157
 158
 159/*!
 160 *  @struct             tstrHostIFscanAttr
 161 *  @brief              Structure to hold Host IF Scan Attributes
 162 *  @details
 163 *  @todo
 164 *  @sa
 165 *  @author             Mostafa Abu Bakr
 166 *  @date               25 March 2012
 167 *  @version            1.0
 168 */
 169typedef struct _tstrHostIFscanAttr {
 170        u8 u8ScanSource;
 171        u8 u8ScanType;
 172        u8 *pu8ChnlFreqList;
 173        u8 u8ChnlListLen;
 174        u8 *pu8IEs;
 175        size_t IEsLen;
 176        tWILCpfScanResult pfScanResult;
 177        void *pvUserArg;
 178        /*BugID_4189*/
 179        tstrHiddenNetwork strHiddenNetwork;
 180
 181} tstrHostIFscanAttr;
 182
 183/*!
 184 *  @struct             tstrHostIFconnectAttr
 185 *  @brief              Structure to hold Host IF Connect Attributes
 186 *  @details
 187 *  @todo
 188 *  @sa
 189 *  @author             Mostafa Abu Bakr
 190 *  @date               25 March 2012
 191 *  @version            1.0
 192 */
 193typedef struct _tstrHostIFconnectAttr {
 194        u8 *pu8bssid;
 195        u8 *pu8ssid;
 196        size_t ssidLen;
 197        u8 *pu8IEs;
 198        size_t IEsLen;
 199        u8 u8security;
 200        tWILCpfConnectResult pfConnectResult;
 201        void *pvUserArg;
 202        AUTHTYPE_T tenuAuth_type;
 203        u8 u8channel;
 204        void *pJoinParams;
 205} tstrHostIFconnectAttr;
 206
 207/*!
 208 *  @struct             tstrRcvdGnrlAsyncInfo
 209 *  @brief              Structure to hold Received General Asynchronous info
 210 *  @details
 211 *  @todo
 212 *  @sa
 213 *  @author             Mostafa Abu Bakr
 214 *  @date               25 March 2012
 215 *  @version            1.0
 216 */
 217typedef struct _tstrRcvdGnrlAsyncInfo {
 218        u8 *pu8Buffer;
 219        u32 u32Length;
 220} tstrRcvdGnrlAsyncInfo;
 221
 222/*!
 223 *  @struct             tstrHostIFSetChan
 224 *  @brief              Set Channel  message body
 225 *  @details
 226 *  @todo
 227 *  @sa
 228 *  @author             Mai Daftedar
 229 *  @date               25 March 2012
 230 *  @version            1.0
 231 */
 232typedef struct _tstrHostIFSetChan {
 233        u8 u8SetChan;
 234} tstrHostIFSetChan;
 235
 236/*!
 237 *  @struct             tstrHostIFSetChan
 238 *  @brief              Get Channel  message body
 239 *  @details
 240 *  @todo
 241 *  @sa
 242 *  @author             Mai Daftedar
 243 *  @date               01 Jule 2012
 244 *  @version            1.0
 245 */
 246typedef struct _tstrHostIFGetChan {
 247        u8 u8GetChan;
 248} tstrHostIFGetChan;
 249
 250/*bug3819: Add Scan acomplete notification to host*/
 251/*!
 252 *  @struct             tstrScanComplete
 253 *  @brief                      hold received Async. Scan Complete message body
 254 *  @details
 255 *  @todo
 256 *  @sa
 257 *  @author             zsalah
 258 *  @date               25 March 2012
 259 *  @version            1.0
 260 */
 261/*typedef struct _tstrScanComplete
 262 * {
 263 *      u8* pu8Buffer;
 264 *      u32 u32Length;
 265 * } tstrScanComplete;*/
 266
 267/*!
 268 *  @struct             tstrHostIFSetBeacon
 269 *  @brief              Set Beacon  message body
 270 *  @details
 271 *  @todo
 272 *  @sa
 273 *  @author             Adham Abozaeid
 274 *  @date               10 July 2012
 275 *  @version            1.0
 276 */
 277typedef struct _tstrHostIFSetBeacon {
 278        u32 u32Interval;                        /*!< Beacon Interval. Period between two successive beacons on air  */
 279        u32 u32DTIMPeriod;              /*!< DTIM Period. Indicates how many Beacon frames
 280                                                                                        *                              (including the current frame) appear before the next DTIM                */
 281        u32 u32HeadLen;                         /*!< Length of the head buffer in bytes         */
 282        u8 *pu8Head;                    /*!< Pointer to the beacon's head buffer. Beacon's head is the part
 283                                                                                        *              from the beacon's start till the TIM element, NOT including the TIM              */
 284        u32 u32TailLen;                         /*!< Length of the tail buffer in bytes */
 285        u8 *pu8Tail;                    /*!< Pointer to the beacon's tail buffer. Beacon's tail starts just
 286                                                                                        *                              after the TIM inormation element */
 287} tstrHostIFSetBeacon;
 288
 289
 290
 291/*!
 292 *  @struct             tstrHostIFDelBeacon
 293 *  @brief              Del Beacon  message body
 294 *  @details
 295 *  @todo
 296 *  @sa
 297 *  @author             Adham Abozaeid
 298 *  @date               15 July 2012
 299 *  @version            1.0
 300 */
 301typedef struct _tstrHostIFDelBeacon {
 302        u8 u8dummy;
 303} tstrHostIFDelBeacon;
 304
 305/*!
 306 *  @struct             tstrHostIFSetMulti
 307 *  @brief              set Multicast filter Address
 308 *  @details
 309 *  @todo
 310 *  @sa
 311 *  @author             Abdelrahman Sobhy
 312 *  @date               30 August 2013
 313 *  @version            1.0 Description
 314 */
 315
 316typedef struct {
 317        bool bIsEnabled;
 318        u32 u32count;
 319} tstrHostIFSetMulti;
 320
 321/*!
 322 *  @struct             tstrHostIFDelAllSta
 323 *  @brief              Deauth station message body
 324 *  @details
 325 *  @todo
 326 *  @sa
 327 *  @author             Mai Daftedar
 328 *  @date               09 April 2014
 329 *  @version            1.0 Description
 330 */
 331
 332typedef struct {
 333        u8 au8Sta_DelAllSta[MAX_NUM_STA][ETH_ALEN];
 334        u8 u8Num_AssocSta;
 335} tstrHostIFDelAllSta;
 336
 337/*!
 338 *  @struct             tstrHostIFDelSta
 339 *  @brief              Delete station message body
 340 *  @details
 341 *  @todo
 342 *  @sa
 343 *  @author             Adham Abozaeid
 344 *  @date               15 July 2012
 345 *  @version            1.0 Description
 346 */
 347
 348typedef struct {
 349        u8 au8MacAddr[ETH_ALEN];
 350} tstrHostIFDelSta;
 351
 352/*!
 353 *  @struct             tstrTimerCb
 354 *  @brief              Timer callback message body
 355 *  @details
 356 *  @todo
 357 *  @sa
 358 *  @author             Mostafa Abu Bakr
 359 *  @date               25 March 2012
 360 *  @version            1.0
 361 */
 362typedef struct _tstrTimerCb {
 363        void *pvUsrArg;                 /*!< Private data passed at timer start */
 364} tstrTimerCb;
 365
 366/*!
 367 *  @struct     tstrHostIfPowerMgmtParam
 368 *  @brief              Power management message body
 369 *  @details
 370 *  @todo
 371 *  @sa
 372 *  @author             Adham Abozaeid
 373 *  @date               24 November 2012
 374 *  @version            1.0
 375 */
 376typedef struct {
 377
 378        bool bIsEnabled;
 379        u32 u32Timeout;
 380} tstrHostIfPowerMgmtParam;
 381
 382/*!
 383 *  @struct             tstrHostIFSetIPAddr
 384 *  @brief              set IP Address message body
 385 *  @details
 386 *  @todo
 387 *  @sa
 388 *  @author             Abdelrahman Sobhy
 389 *  @date               30 August 2013
 390 *  @version            1.0 Description
 391 */
 392
 393typedef struct {
 394        u8 *au8IPAddr;
 395        u8 idx;
 396} tstrHostIFSetIPAddr;
 397
 398/*!
 399 *  @struct     tstrHostIfStaInactiveT
 400 *  @brief              Get station message body
 401 *  @details
 402 *  @todo
 403 *  @sa
 404 *  @author         Mai Daftedar
 405 *  @date               16 April 2013
 406 *  @version            1.0
 407 */
 408typedef struct {
 409        u8 mac[6];
 410
 411} tstrHostIfStaInactiveT;
 412/**/
 413/*!
 414 *  @union              tuniHostIFmsgBody
 415 *  @brief              Message body for the Host Interface message_q
 416 *  @details
 417 *  @todo
 418 *  @sa
 419 *  @author             Mostafa Abu Bakr
 420 *  @date               25 March 2012
 421 *  @version            1.0
 422 */
 423typedef union _tuniHostIFmsgBody {
 424        tstrHostIFscanAttr strHostIFscanAttr;                           /*!< Host IF Scan Request Attributes message body */
 425        tstrHostIFconnectAttr strHostIFconnectAttr;     /*!< Host IF Connect Request Attributes message body */
 426        tstrRcvdNetworkInfo strRcvdNetworkInfo;                 /*!< Received Asynchronous Network Info message body */
 427        tstrRcvdGnrlAsyncInfo strRcvdGnrlAsyncInfo;     /*!< Received General Asynchronous Info message body */
 428        tstrHostIFkeyAttr strHostIFkeyAttr;                             /*!<>*/
 429        tstrHostIFCfgParamAttr strHostIFCfgParamAttr;            /*! <CFG Parameter message Body> */
 430        tstrHostIFSetChan strHostIFSetChan;
 431        tstrHostIFGetChan strHostIFGetChan;
 432        tstrHostIFSetBeacon strHostIFSetBeacon;                 /*!< Set beacon message body */
 433        tstrHostIFDelBeacon strHostIFDelBeacon;                 /*!< Del beacon message body */
 434        tstrWILC_AddStaParam strAddStaParam;                    /*!< Add station message body */
 435        tstrHostIFDelSta strDelStaParam;                                /*!< Del Station message body */
 436        tstrWILC_AddStaParam strEditStaParam;                           /*!< Edit station message body */
 437        /* tstrScanComplete             strScanComplete;                / *Received Async. Scan Complete message body* / */
 438        tstrTimerCb strTimerCb;                                                 /*!< Timer callback message body */
 439        tstrHostIfPowerMgmtParam strPowerMgmtparam;     /*!< Power Management message body */
 440        tstrHostIfStaInactiveT strHostIfStaInactiveT;
 441        tstrHostIFSetIPAddr strHostIfSetIP;
 442        tstrHostIfSetDrvHandler strHostIfSetDrvHandler;
 443        tstrHostIFSetMulti strHostIfSetMulti;
 444        tstrHostIfSetOperationMode strHostIfSetOperationMode;
 445        tstrHostIfSetMacAddress strHostIfSetMacAddress;
 446        tstrHostIfGetMacAddress strHostIfGetMacAddress;
 447        tstrHostIfBASessionInfo strHostIfBASessionInfo;
 448        #ifdef WILC_P2P
 449        tstrHostIfRemainOnChan strHostIfRemainOnChan;
 450        tstrHostIfRegisterFrame strHostIfRegisterFrame;
 451        #endif
 452        char *pUserData;
 453        tstrHostIFDelAllSta strHostIFDelAllSta;
 454} tuniHostIFmsgBody;
 455
 456/*!
 457 *  @struct             tstrHostIFmsg
 458 *  @brief              Host Interface message
 459 *  @details
 460 *  @todo
 461 *  @sa
 462 *  @author             Mostafa Abu Bakr
 463 *  @date               25 March 2012
 464 *  @version            1.0
 465 */
 466typedef struct _tstrHostIFmsg {
 467        u16 u16MsgId;                                           /*!< Message ID */
 468        tuniHostIFmsgBody uniHostIFmsgBody;             /*!< Message body */
 469        tstrWILC_WFIDrv *drvHandler;
 470} tstrHostIFmsg;
 471
 472#ifdef CONNECT_DIRECT
 473typedef struct _tstrWidJoinReqExt {
 474        char SSID[MAX_SSID_LEN];
 475        u8 u8channel;
 476        u8 BSSID[6];
 477} tstrWidJoinReqExt;
 478#endif
 479
 480/*Bug4218: Parsing Join Param*/
 481#ifdef WILC_PARSE_SCAN_IN_HOST
 482/*Struct containg joinParam of each AP*/
 483typedef struct _tstrJoinBssParam {
 484        BSSTYPE_T bss_type;
 485        u8 dtim_period;
 486        u16 beacon_period;
 487        u16 cap_info;
 488        u8 au8bssid[6];
 489        char ssid[MAX_SSID_LEN];
 490        u8 ssidLen;
 491        u8 supp_rates[MAX_RATES_SUPPORTED + 1];
 492        u8 ht_capable;
 493        u8 wmm_cap;
 494        u8 uapsd_cap;
 495        bool rsn_found;
 496        u8 rsn_grp_policy;
 497        u8 mode_802_11i;
 498        u8 rsn_pcip_policy[3];
 499        u8 rsn_auth_policy[3];
 500        u8 rsn_cap[2];
 501        struct _tstrJoinParam *nextJoinBss;
 502        #ifdef WILC_P2P
 503        u32 tsf;
 504        u8 u8NoaEnbaled;
 505        u8 u8OppEnable;
 506        u8 u8CtWindow;
 507        u8 u8Count;
 508        u8 u8Index;
 509        u8 au8Duration[4];
 510        u8 au8Interval[4];
 511        u8 au8StartTime[4];
 512        #endif
 513} tstrJoinBssParam;
 514/*Bug4218: Parsing Join Param*/
 515/*a linked list table containing needed join parameters entries for each AP found in most recent scan*/
 516typedef struct _tstrBssTable {
 517        u8 u8noBssEntries;
 518        tstrJoinBssParam *head;
 519        tstrJoinBssParam *tail;
 520} tstrBssTable;
 521#endif /*WILC_PARSE_SCAN_IN_HOST*/
 522
 523typedef enum {
 524        SCAN_TIMER = 0,
 525        CONNECT_TIMER   = 1,
 526        SCAN_CONNECT_TIMER_FORCE_32BIT = 0xFFFFFFFF
 527} tenuScanConnTimer;
 528
 529/*****************************************************************************/
 530/*                                                                                                                                                       */
 531/*                                                      Global Variabls                                                                  */
 532/*                                                                                                                                                       */
 533/*****************************************************************************/
 534
 535
 536tstrWILC_WFIDrv *terminated_handle;
 537tstrWILC_WFIDrv *gWFiDrvHandle;
 538#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
 539bool g_obtainingIP = false;
 540#endif
 541u8 P2P_LISTEN_STATE;
 542static struct task_struct *HostIFthreadHandler;
 543static WILC_MsgQueueHandle gMsgQHostIF;
 544static struct semaphore hSemHostIFthrdEnd;
 545
 546struct semaphore hSemDeinitDrvHandle;
 547static struct semaphore hWaitResponse;
 548struct semaphore hSemHostIntDeinit;
 549struct timer_list g_hPeriodicRSSI;
 550
 551
 552
 553u8 gau8MulticastMacAddrList[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN];
 554
 555#ifndef CONNECT_DIRECT
 556static u8 gapu8RcvdSurveyResults[2][MAX_SURVEY_RESULT_FRAG_SIZE];
 557#endif
 558
 559static u8 gapu8RcvdAssocResp[MAX_ASSOC_RESP_FRAME_SIZE];
 560
 561bool gbScanWhileConnected = false;
 562
 563static s8 gs8Rssi;
 564static s8 gs8lnkspd;
 565static u8 gu8Chnl;
 566static u8 gs8SetIP[2][4];
 567static u8 gs8GetIP[2][4];
 568#ifdef WILC_AP_EXTERNAL_MLME
 569static u32 gu32InactiveTime;
 570static u8 gu8DelBcn;
 571#endif
 572static u32 gu32WidConnRstHack;
 573
 574/*BugID_5137*/
 575u8 *gu8FlushedJoinReq;
 576u8 *gu8FlushedInfoElemAsoc;
 577u8 gu8Flushed11iMode;
 578u8 gu8FlushedAuthType;
 579u32 gu32FlushedJoinReqSize;
 580u32 gu32FlushedInfoElemAsocSize;
 581u32 gu8FlushedJoinReqDrvHandler;
 582#define REAL_JOIN_REQ 0
 583#define FLUSHED_JOIN_REQ 1
 584#define FLUSHED_BYTE_POS 79     /* Position the byte indicating flushing in the flushed request */
 585
 586/*Bug4218: Parsing Join Param*/
 587#ifdef WILC_PARSE_SCAN_IN_HOST
 588/*Bug4218: Parsing Join Param*/
 589static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo);
 590#endif /*WILC_PARSE_SCAN_IN_HOST*/
 591
 592extern void chip_sleep_manually(u32 u32SleepTime);
 593extern int linux_wlan_get_num_conn_ifcs(void);
 594
 595/**
 596 *  @brief Handle_SetChannel
 597 *  @details    Sending config packet to firmware to set channel
 598 *  @param[in]   tstrHostIFSetChan* pstrHostIFSetChan
 599 *  @return     Error code.
 600 *  @author
 601 *  @date
 602 *  @version    1.0
 603 */
 604static s32 Handle_SetChannel(tstrWILC_WFIDrv *drvHandler, tstrHostIFSetChan *pstrHostIFSetChan)
 605{
 606
 607        s32 s32Error = WILC_SUCCESS;
 608        tstrWID strWID;
 609        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
 610
 611        /*prepare configuration packet*/
 612        strWID.u16WIDid = (u16)WID_CURRENT_CHANNEL;
 613        strWID.enuWIDtype = WID_CHAR;
 614        strWID.ps8WidVal = (char *)&(pstrHostIFSetChan->u8SetChan);
 615        strWID.s32ValueSize = sizeof(char);
 616
 617        PRINT_D(HOSTINF_DBG, "Setting channel\n");
 618        /*Sending Cfg*/
 619        s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
 620        if (s32Error) {
 621                PRINT_ER("Failed to set channel\n");
 622                WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
 623        }
 624        WILC_CATCH(s32Error)
 625        {
 626
 627        }
 628
 629        return s32Error;
 630}
 631/**
 632 *  @brief Handle_SetWfiDrvHandler
 633 *  @details    Sending config packet to firmware to set driver handler
 634 *  @param[in]   void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
 635 *  @return     Error code.
 636 *  @author
 637 *  @date
 638 *  @version    1.0
 639 */
 640static s32 Handle_SetWfiDrvHandler(tstrHostIfSetDrvHandler *pstrHostIfSetDrvHandler)
 641{
 642
 643        s32 s32Error = WILC_SUCCESS;
 644        tstrWID strWID;
 645        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)((pstrHostIfSetDrvHandler->u32Address));
 646
 647
 648        /*prepare configuration packet*/
 649        strWID.u16WIDid = (u16)WID_SET_DRV_HANDLER;
 650        strWID.enuWIDtype = WID_INT;
 651        strWID.ps8WidVal = (s8 *)&(pstrHostIfSetDrvHandler->u32Address);
 652        strWID.s32ValueSize = sizeof(u32);
 653
 654        /*Sending Cfg*/
 655
 656        s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
 657
 658
 659        if ((pstrHostIfSetDrvHandler->u32Address) == (u32)NULL)
 660                up(&hSemDeinitDrvHandle);
 661
 662
 663        if (s32Error) {
 664                PRINT_ER("Failed to set driver handler\n");
 665                WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
 666        }
 667        WILC_CATCH(s32Error)
 668        {
 669
 670        }
 671
 672        return s32Error;
 673}
 674
 675/**
 676 *  @brief Handle_SetWfiAPDrvHandler
 677 *  @details    Sending config packet to firmware to set driver handler
 678 *  @param[in]   void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
 679 *  @return     Error code.
 680 *  @author
 681 *  @date
 682 *  @version    1.0
 683 */
 684static s32 Handle_SetOperationMode(tstrWILC_WFIDrv *drvHandler, tstrHostIfSetOperationMode *pstrHostIfSetOperationMode)
 685{
 686
 687        s32 s32Error = WILC_SUCCESS;
 688        tstrWID strWID;
 689        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
 690
 691
 692        /*prepare configuration packet*/
 693        strWID.u16WIDid = (u16)WID_SET_OPERATION_MODE;
 694        strWID.enuWIDtype = WID_INT;
 695        strWID.ps8WidVal = (s8 *)&(pstrHostIfSetOperationMode->u32Mode);
 696        strWID.s32ValueSize = sizeof(u32);
 697
 698        /*Sending Cfg*/
 699        PRINT_INFO(HOSTINF_DBG, "pstrWFIDrv= %p\n", pstrWFIDrv);
 700
 701        s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
 702
 703
 704        if ((pstrHostIfSetOperationMode->u32Mode) == (u32)NULL)
 705                up(&hSemDeinitDrvHandle);
 706
 707
 708        if (s32Error) {
 709                PRINT_ER("Failed to set driver handler\n");
 710                WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
 711        }
 712        WILC_CATCH(s32Error)
 713        {
 714
 715        }
 716
 717        return s32Error;
 718}
 719
 720/**
 721 *  @brief host_int_set_IPAddress
 722 *  @details       Setting IP address params in message queue
 723 *  @param[in]    WILC_WFIDrvHandle hWFIDrv, u8* pu8IPAddr
 724 *  @return         Error code.
 725 *  @author
 726 *  @date
 727 *  @version    1.0
 728 */
 729s32 Handle_set_IPAddress(tstrWILC_WFIDrv *drvHandler, u8 *pu8IPAddr, u8 idx)
 730{
 731
 732        s32 s32Error = WILC_SUCCESS;
 733        tstrWID strWID;
 734        char firmwareIPAddress[4] = {0};
 735        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
 736
 737        if (pu8IPAddr[0] < 192)
 738                pu8IPAddr[0] = 0;
 739
 740        PRINT_INFO(HOSTINF_DBG, "Indx = %d, Handling set  IP = %pI4\n", idx, pu8IPAddr);
 741
 742        memcpy(gs8SetIP[idx], pu8IPAddr, IP_ALEN);
 743
 744        /*prepare configuration packet*/
 745        strWID.u16WIDid = (u16)WID_IP_ADDRESS;
 746        strWID.enuWIDtype = WID_STR;
 747        strWID.ps8WidVal = (u8 *)pu8IPAddr;
 748        strWID.s32ValueSize = IP_ALEN;
 749
 750        s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
 751
 752
 753
 754        host_int_get_ipaddress(drvHandler, firmwareIPAddress, idx);
 755
 756        if (s32Error) {
 757                PRINT_D(HOSTINF_DBG, "Failed to set IP address\n");
 758                WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
 759        } else {
 760                PRINT_INFO(HOSTINF_DBG, "IP address set\n");
 761        }
 762
 763        WILC_CATCH(s32Error)
 764        {
 765
 766        }
 767
 768        return s32Error;
 769}
 770
 771
 772/**
 773 *  @brief Handle_get_IPAddress
 774 *  @details       Setting IP address params in message queue
 775 *  @param[in]    WILC_WFIDrvHandle hWFIDrv, u8* pu8IPAddr
 776 *  @return         Error code.
 777 *  @author
 778 *  @date
 779 *  @version    1.0
 780 */
 781s32 Handle_get_IPAddress(tstrWILC_WFIDrv *drvHandler, u8 *pu8IPAddr, u8 idx)
 782{
 783
 784        s32 s32Error = WILC_SUCCESS;
 785        tstrWID strWID;
 786        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
 787
 788        /*prepare configuration packet*/
 789        strWID.u16WIDid = (u16)WID_IP_ADDRESS;
 790        strWID.enuWIDtype = WID_STR;
 791        strWID.ps8WidVal = WILC_MALLOC(IP_ALEN);
 792        strWID.s32ValueSize = IP_ALEN;
 793
 794        s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
 795
 796        PRINT_INFO(HOSTINF_DBG, "%pI4\n", strWID.ps8WidVal);
 797
 798        memcpy(gs8GetIP[idx], strWID.ps8WidVal, IP_ALEN);
 799
 800        /*get the value by searching the local copy*/
 801        kfree(strWID.ps8WidVal);
 802
 803        if (memcmp(gs8GetIP[idx], gs8SetIP[idx], IP_ALEN) != 0)
 804                host_int_setup_ipaddress(pstrWFIDrv, gs8SetIP[idx], idx);
 805
 806        if (s32Error != WILC_SUCCESS) {
 807                PRINT_ER("Failed to get IP address\n");
 808                WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
 809        } else {
 810                PRINT_INFO(HOSTINF_DBG, "IP address retrieved:: u8IfIdx = %d\n", idx);
 811                PRINT_INFO(HOSTINF_DBG, "%pI4\n", gs8GetIP[idx]);
 812                PRINT_INFO(HOSTINF_DBG, "\n");
 813        }
 814
 815        WILC_CATCH(s32Error)
 816        {
 817
 818        }
 819
 820        return s32Error;
 821}
 822
 823
 824/*BugId_5077*/
 825/**
 826 *  @brief Handle_SetMacAddress
 827 *  @details    Setting mac address
 828 *  @param[in]   void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
 829 *  @return     Error code.
 830 *  @author     Amr Abdel-Moghny
 831 *  @date               November 2013
 832 *  @version    7.0
 833 */
 834static s32 Handle_SetMacAddress(tstrWILC_WFIDrv *drvHandler, tstrHostIfSetMacAddress *pstrHostIfSetMacAddress)
 835{
 836
 837        s32 s32Error = WILC_SUCCESS;
 838        tstrWID strWID;
 839        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
 840        u8 *mac_buf = WILC_MALLOC(ETH_ALEN);
 841
 842        if (mac_buf == NULL) {
 843                PRINT_ER("No buffer to send mac address\n");
 844                return WILC_FAIL;
 845        }
 846        memcpy(mac_buf, pstrHostIfSetMacAddress->u8MacAddress, ETH_ALEN);
 847
 848        /*prepare configuration packet*/
 849        strWID.u16WIDid = (u16)WID_MAC_ADDR;
 850        strWID.enuWIDtype = WID_STR;
 851        strWID.ps8WidVal = mac_buf;
 852        strWID.s32ValueSize = ETH_ALEN;
 853        PRINT_D(GENERIC_DBG, "mac addr = :%x:%x:%x:%x:%x:%x\n", strWID.ps8WidVal[0], strWID.ps8WidVal[1], strWID.ps8WidVal[2], strWID.ps8WidVal[3], strWID.ps8WidVal[4], strWID.ps8WidVal[5]);
 854        /*Sending Cfg*/
 855        s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
 856        if (s32Error) {
 857                PRINT_ER("Failed to set mac address\n");
 858                WILC_ERRORREPORT(s32Error, WILC_FAIL);
 859        }
 860
 861        WILC_CATCH(s32Error)
 862        {
 863
 864        }
 865        kfree(mac_buf);
 866        return s32Error;
 867}
 868
 869
 870/*BugID_5213*/
 871/**
 872 *  @brief Handle_GetMacAddress
 873 *  @details    Getting mac address
 874 *  @param[in]   void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
 875 *  @return     Error code.
 876 *  @author     Amr Abdel-Moghny
 877 *  @date               JAN 2013
 878 *  @version    8.0
 879 */
 880static s32 Handle_GetMacAddress(tstrWILC_WFIDrv *drvHandler, tstrHostIfGetMacAddress *pstrHostIfGetMacAddress)
 881{
 882
 883        s32 s32Error = WILC_SUCCESS;
 884        tstrWID strWID;
 885
 886        /*prepare configuration packet*/
 887        strWID.u16WIDid = (u16)WID_MAC_ADDR;
 888        strWID.enuWIDtype = WID_STR;
 889        strWID.ps8WidVal = pstrHostIfGetMacAddress->u8MacAddress;
 890        strWID.s32ValueSize = ETH_ALEN;
 891
 892        /*Sending Cfg*/
 893        s32Error = SendConfigPkt(GET_CFG, &strWID, 1, false, (u32)drvHandler);
 894        if (s32Error) {
 895                PRINT_ER("Failed to get mac address\n");
 896                WILC_ERRORREPORT(s32Error, WILC_FAIL);
 897        }
 898        WILC_CATCH(s32Error)
 899        {
 900
 901        }
 902        up(&hWaitResponse);
 903
 904        return s32Error;
 905}
 906
 907
 908/**
 909 *  @brief Handle_CfgParam
 910 *  @details    Sending config packet to firmware to set CFG params
 911 *  @param[in]   tstrHostIFCfgParamAttr* strHostIFCfgParamAttr
 912 *  @return     Error code.
 913 *  @author
 914 *  @date
 915 *  @version    1.0
 916 */
 917static s32 Handle_CfgParam(tstrWILC_WFIDrv *drvHandler, tstrHostIFCfgParamAttr *strHostIFCfgParamAttr)
 918{
 919        s32 s32Error = WILC_SUCCESS;
 920        tstrWID strWIDList[32];
 921        u8 u8WidCnt = 0;
 922        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
 923
 924
 925        down(&(pstrWFIDrv->gtOsCfgValuesSem));
 926
 927
 928        PRINT_D(HOSTINF_DBG, "Setting CFG params\n");
 929
 930        if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & BSS_TYPE) {
 931                /*----------------------------------------------------------*/
 932                /*Input Value:  INFRASTRUCTURE = 1,                                                     */
 933                /*                              INDEPENDENT= 2,                                                         */
 934                /*                              ANY_BSS= 3                                                                      */
 935                /*----------------------------------------------------------*/
 936                /* validate input then copy>> need to check value 4 and 5 */
 937                if (strHostIFCfgParamAttr->pstrCfgParamVal.bss_type < 6) {
 938                        strWIDList[u8WidCnt].u16WIDid = WID_BSS_TYPE;
 939                        strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.bss_type;
 940                        strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
 941                        strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
 942                        pstrWFIDrv->strCfgValues.bss_type = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.bss_type;
 943                } else {
 944                        WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
 945                }
 946                u8WidCnt++;
 947        }
 948        if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & AUTH_TYPE) {
 949                /*------------------------------------------------------*/
 950                /*Input Values: OPEN_SYSTEM     = 0,                                    */
 951                /*                              SHARED_KEY      = 1,                                    */
 952                /*                              ANY             = 2                                             */
 953                /*------------------------------------------------------*/
 954                /*validate Possible values*/
 955                if ((strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 1 || (strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 2 || (strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 5) {
 956                        strWIDList[u8WidCnt].u16WIDid = WID_AUTH_TYPE;
 957                        strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.auth_type;
 958                        strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
 959                        strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
 960                        pstrWFIDrv->strCfgValues.auth_type = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.auth_type;
 961                } else {
 962                        WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
 963                }
 964                u8WidCnt++;
 965        }
 966        if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & AUTHEN_TIMEOUT) {
 967                /* range is 1 to 65535. */
 968                if (strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout < 65536) {
 969                        strWIDList[u8WidCnt].u16WIDid = WID_AUTH_TIMEOUT;
 970                        strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout;
 971                        strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
 972                        strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
 973                        pstrWFIDrv->strCfgValues.auth_timeout = strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout;
 974                } else {
 975                        WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
 976                }
 977                u8WidCnt++;
 978        }
 979        if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & POWER_MANAGEMENT) {
 980                /*-----------------------------------------------------------*/
 981                /*Input Values: NO_POWERSAVE     = 0,                                           */
 982                /*                              MIN_FAST_PS      = 1,                                           */
 983                /*                              MAX_FAST_PS      = 2,                                           */
 984                /*                              MIN_PSPOLL_PS    = 3,                                           */
 985                /*                              MAX_PSPOLL_PS    = 4                                            */
 986                /*----------------------------------------------------------*/
 987                if (strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode < 5) {
 988                        strWIDList[u8WidCnt].u16WIDid = WID_POWER_MANAGEMENT;
 989                        strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode;
 990                        strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
 991                        strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
 992                        pstrWFIDrv->strCfgValues.power_mgmt_mode = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode;
 993                } else {
 994                        WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
 995                }
 996                u8WidCnt++;
 997        }
 998        if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RETRY_SHORT) {
 999                /* range from 1 to 256 */
1000                if ((strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit > 0) && (strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit < 256)) {
1001                        strWIDList[u8WidCnt].u16WIDid = WID_SHORT_RETRY_LIMIT;
1002                        strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit;
1003                        strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1004                        strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1005                        pstrWFIDrv->strCfgValues.short_retry_limit = strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit;
1006                } else {
1007                        WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1008                }
1009                u8WidCnt++;
1010        }
1011        if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RETRY_LONG) {
1012                /* range from 1 to 256 */
1013                if ((strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit > 0) && (strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit < 256)) {
1014                        strWIDList[u8WidCnt].u16WIDid = WID_LONG_RETRY_LIMIT;
1015                        strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit;
1016
1017                        strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1018                        strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1019                        pstrWFIDrv->strCfgValues.long_retry_limit = strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit;
1020                } else {
1021                        WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1022                }
1023                u8WidCnt++;
1024        }
1025        if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & FRAG_THRESHOLD) {
1026
1027                if (strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold > 255 && strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold < 7937) {
1028                        strWIDList[u8WidCnt].u16WIDid = WID_FRAG_THRESHOLD;
1029                        strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold;
1030                        strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1031                        strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1032                        pstrWFIDrv->strCfgValues.frag_threshold = strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold;
1033                } else {
1034                        WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1035                }
1036                u8WidCnt++;
1037        }
1038        if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RTS_THRESHOLD) {
1039                /* range 256 to 65535 */
1040                if (strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold > 255 && strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold < 65536) {
1041                        strWIDList[u8WidCnt].u16WIDid = WID_RTS_THRESHOLD;
1042                        strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold;
1043                        strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1044                        strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1045                        pstrWFIDrv->strCfgValues.rts_threshold = strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold;
1046                } else {
1047                        WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1048                }
1049                u8WidCnt++;
1050        }
1051        if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & PREAMBLE) {
1052                /*-----------------------------------------------------*/
1053                /*Input Values: Short= 0,                                                               */
1054                /*                              Long= 1,                                */
1055                /*                              Auto= 2                                                                 */
1056                /*------------------------------------------------------*/
1057                if (strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type < 3) {
1058                        strWIDList[u8WidCnt].u16WIDid = WID_PREAMBLE;
1059                        strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type;
1060                        strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
1061                        strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
1062                        pstrWFIDrv->strCfgValues.preamble_type = strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type;
1063                } else {
1064                        WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1065                }
1066                u8WidCnt++;
1067        }
1068        if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SHORT_SLOT_ALLOWED) {
1069                if (strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed < 2) {
1070                        strWIDList[u8WidCnt].u16WIDid = WID_SHORT_SLOT_ALLOWED;
1071                        strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed;
1072                        strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
1073                        strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
1074                        pstrWFIDrv->strCfgValues.short_slot_allowed = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed;
1075                } else {
1076                        WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1077                }
1078                u8WidCnt++;
1079        }
1080        if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & TXOP_PROT_DISABLE) {
1081                /*Description:  used to Disable RTS-CTS protection for TXOP burst*/
1082                /*transmission when the acknowledgement policy is No-Ack or Block-Ack   */
1083                /* this information is useful for external supplicant                                   */
1084                /*Input Values: 1 for enable and 0 for disable.                                                 */
1085                if (strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled < 2) {
1086                        strWIDList[u8WidCnt].u16WIDid = WID_11N_TXOP_PROT_DISABLE;
1087                        strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled;
1088                        strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
1089                        strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
1090                        pstrWFIDrv->strCfgValues.txop_prot_disabled = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled;
1091                } else {
1092                        WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1093                }
1094                u8WidCnt++;
1095        }
1096        if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & BEACON_INTERVAL) {
1097                /* range is 1 to 65535. */
1098                if (strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval < 65536) {
1099                        strWIDList[u8WidCnt].u16WIDid = WID_BEACON_INTERVAL;
1100                        strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval;
1101                        strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1102                        strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1103                        pstrWFIDrv->strCfgValues.beacon_interval = strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval;
1104                } else {
1105                        WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1106                }
1107                u8WidCnt++;
1108        }
1109        if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & DTIM_PERIOD) {
1110                /* range is 1 to 255. */
1111                if (strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period < 256) {
1112                        strWIDList[u8WidCnt].u16WIDid = WID_DTIM_PERIOD;
1113                        strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period;
1114                        strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
1115                        strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
1116                        pstrWFIDrv->strCfgValues.dtim_period = strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period;
1117                } else {
1118                        WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1119                }
1120                u8WidCnt++;
1121        }
1122        if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SITE_SURVEY) {
1123                /*----------------------------------------------------------------------*/
1124                /*Input Values: SITE_SURVEY_1CH    = 0, i.e.: currently set channel             */
1125                /*                              SITE_SURVEY_ALL_CH = 1,                                                                 */
1126                /*                              SITE_SURVEY_OFF    = 2                                                                  */
1127                /*----------------------------------------------------------------------*/
1128                if (strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled < 3) {
1129                        strWIDList[u8WidCnt].u16WIDid = WID_SITE_SURVEY;
1130                        strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled;
1131                        strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
1132                        strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
1133                        pstrWFIDrv->strCfgValues.site_survey_enabled = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled;
1134                } else {
1135                        WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1136                }
1137                u8WidCnt++;
1138        }
1139        if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SITE_SURVEY_SCAN_TIME) {
1140                /* range is 1 to 65535. */
1141                if (strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time < 65536) {
1142                        strWIDList[u8WidCnt].u16WIDid = WID_SITE_SURVEY_SCAN_TIME;
1143                        strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time;
1144                        strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1145                        strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1146                        pstrWFIDrv->strCfgValues.site_survey_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time;
1147                } else {
1148                        WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1149                }
1150                u8WidCnt++;
1151        }
1152        if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & ACTIVE_SCANTIME) {
1153                /* range is 1 to 65535. */
1154                if (strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time < 65536) {
1155                        strWIDList[u8WidCnt].u16WIDid = WID_ACTIVE_SCAN_TIME;
1156                        strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time;
1157                        strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1158                        strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1159                        pstrWFIDrv->strCfgValues.active_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time;
1160                } else {
1161                        WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1162                }
1163                u8WidCnt++;
1164        }
1165        if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & PASSIVE_SCANTIME) {
1166                /* range is 1 to 65535. */
1167                if (strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time < 65536) {
1168                        strWIDList[u8WidCnt].u16WIDid = WID_PASSIVE_SCAN_TIME;
1169                        strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time;
1170                        strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1171                        strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1172                        pstrWFIDrv->strCfgValues.passive_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time;
1173                } else {
1174                        WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1175                }
1176                u8WidCnt++;
1177        }
1178        if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & CURRENT_TX_RATE) {
1179                CURRENT_TX_RATE_T curr_tx_rate = strHostIFCfgParamAttr->pstrCfgParamVal.curr_tx_rate;
1180                /*----------------------------------------------------------------------*/
1181                /*Rates:                1   2   5.5   11   6  9  12  18  24  36  48   54  Auto  */
1182                /*InputValues:  1   2     3    4   5  6   7   8   9  10  11   12  0             */
1183                /*----------------------------------------------------------------------*/
1184                /* validate rate */
1185                if (curr_tx_rate == AUTORATE || curr_tx_rate == MBPS_1
1186                    || curr_tx_rate == MBPS_2 || curr_tx_rate == MBPS_5_5
1187                    || curr_tx_rate == MBPS_11 || curr_tx_rate == MBPS_6
1188                    || curr_tx_rate == MBPS_9 || curr_tx_rate == MBPS_12
1189                    || curr_tx_rate == MBPS_18 || curr_tx_rate == MBPS_24
1190                    || curr_tx_rate == MBPS_36 || curr_tx_rate == MBPS_48 || curr_tx_rate == MBPS_54) {
1191                        strWIDList[u8WidCnt].u16WIDid = WID_CURRENT_TX_RATE;
1192                        strWIDList[u8WidCnt].ps8WidVal = (s8 *)&curr_tx_rate;
1193                        strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1194                        strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1195                        pstrWFIDrv->strCfgValues.curr_tx_rate = (u8)curr_tx_rate;
1196                } else {
1197                        WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1198                }
1199                u8WidCnt++;
1200        }
1201        s32Error = SendConfigPkt(SET_CFG, strWIDList, u8WidCnt, false, (u32)pstrWFIDrv);
1202
1203        if (s32Error)
1204                PRINT_ER("Error in setting CFG params\n");
1205
1206        WILC_CATCH(s32Error)
1207        {
1208        }
1209        up(&(pstrWFIDrv->gtOsCfgValuesSem));
1210        return s32Error;
1211}
1212
1213
1214/**
1215 *  @brief Handle_wait_msg_q_empty
1216 *  @details       this should be the last msg and then the msg Q becomes idle
1217 *  @param[in]    tstrHostIFscanAttr* pstrHostIFscanAttr
1218 *  @return         Error code.
1219 *  @author
1220 *  @date
1221 *  @version    1.0
1222 */
1223static s32 Handle_wait_msg_q_empty(void)
1224{
1225        s32 s32Error = WILC_SUCCESS;
1226
1227        g_wilc_initialized = 0;
1228        up(&hWaitResponse);
1229        return s32Error;
1230}
1231
1232/**
1233 *  @brief Handle_Scan
1234 *  @details       Sending config packet to firmware to set the scan params
1235 *  @param[in]    tstrHostIFscanAttr* pstrHostIFscanAttr
1236 *  @return         Error code.
1237 *  @author
1238 *  @date
1239 *  @version    1.0
1240 */
1241static s32 Handle_Scan(tstrWILC_WFIDrv *drvHandler, tstrHostIFscanAttr *pstrHostIFscanAttr)
1242{
1243        s32 s32Error = WILC_SUCCESS;
1244        tstrWID strWIDList[5];
1245        u32 u32WidsCount = 0;
1246        u32 i;
1247        u8 *pu8Buffer;
1248        u8 valuesize = 0;
1249        u8 *pu8HdnNtwrksWidVal = NULL;
1250        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
1251
1252        PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
1253        PRINT_D(HOSTINF_DBG, "Scanning: In [%d] state\n", pstrWFIDrv->enuHostIFstate);
1254
1255        pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = pstrHostIFscanAttr->pfScanResult;
1256        pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid = pstrHostIFscanAttr->pvUserArg;
1257
1258        #ifdef WILC_P2P
1259        #endif
1260
1261        if ((pstrWFIDrv->enuHostIFstate >= HOST_IF_SCANNING) && (pstrWFIDrv->enuHostIFstate < HOST_IF_CONNECTED)) {
1262                /* here we either in HOST_IF_SCANNING, HOST_IF_WAITING_CONN_REQ or HOST_IF_WAITING_CONN_RESP */
1263                PRINT_D(GENERIC_DBG, "Don't scan we are already in [%d] state\n", pstrWFIDrv->enuHostIFstate);
1264                WILC_ERRORREPORT(s32Error, WILC_BUSY);
1265        }
1266
1267        #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
1268        if (g_obtainingIP || connecting) {
1269                PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
1270                WILC_ERRORREPORT(s32Error, WILC_BUSY);
1271        }
1272        #endif
1273
1274        PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
1275
1276
1277        pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount = 0;
1278
1279        /*BugID_4189*/
1280        strWIDList[u32WidsCount].u16WIDid = (u16)WID_SSID_PROBE_REQ;
1281        strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1282
1283        for (i = 0; i < pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum; i++)
1284                valuesize += ((pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen) + 1);
1285        pu8HdnNtwrksWidVal = WILC_MALLOC(valuesize + 1);
1286        strWIDList[u32WidsCount].ps8WidVal = pu8HdnNtwrksWidVal;
1287        if (strWIDList[u32WidsCount].ps8WidVal != NULL) {
1288                pu8Buffer = strWIDList[u32WidsCount].ps8WidVal;
1289
1290                *pu8Buffer++ = pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum;
1291
1292                PRINT_D(HOSTINF_DBG, "In Handle_ProbeRequest number of ssid %d\n", pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum);
1293
1294                for (i = 0; i < pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum; i++) {
1295                        *pu8Buffer++ = pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen;
1296                        memcpy(pu8Buffer, pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid, pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen);
1297                        pu8Buffer += pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen;
1298                }
1299
1300
1301
1302                strWIDList[u32WidsCount].s32ValueSize =  (s32)(valuesize + 1);
1303                u32WidsCount++;
1304        }
1305
1306        /*filling cfg param array*/
1307
1308        /* if((pstrHostIFscanAttr->pu8IEs != NULL) && (pstrHostIFscanAttr->IEsLen != 0)) */
1309        {
1310                /* IEs to be inserted in Probe Request */
1311                strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_PROBE;
1312                strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1313                strWIDList[u32WidsCount].ps8WidVal = pstrHostIFscanAttr->pu8IEs;
1314                strWIDList[u32WidsCount].s32ValueSize = pstrHostIFscanAttr->IEsLen;
1315                u32WidsCount++;
1316        }
1317
1318        /*Scan Type*/
1319        strWIDList[u32WidsCount].u16WIDid = WID_SCAN_TYPE;
1320        strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
1321        strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
1322        strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrHostIFscanAttr->u8ScanType));
1323        u32WidsCount++;
1324
1325        /*list of channels to be scanned*/
1326        strWIDList[u32WidsCount].u16WIDid = WID_SCAN_CHANNEL_LIST;
1327        strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1328
1329        /* Bug 4648: Convert channel numbers to start from 0 not 1. */
1330        if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL && pstrHostIFscanAttr->u8ChnlListLen > 0) {
1331                int i;
1332
1333                for (i = 0; i < pstrHostIFscanAttr->u8ChnlListLen; i++) {
1334                        if (pstrHostIFscanAttr->pu8ChnlFreqList[i] > 0)
1335                                pstrHostIFscanAttr->pu8ChnlFreqList[i] = pstrHostIFscanAttr->pu8ChnlFreqList[i] - 1;
1336                }
1337        }
1338
1339        strWIDList[u32WidsCount].ps8WidVal = pstrHostIFscanAttr->pu8ChnlFreqList;
1340        strWIDList[u32WidsCount].s32ValueSize = pstrHostIFscanAttr->u8ChnlListLen;
1341        u32WidsCount++;
1342
1343        /*Scan Request*/
1344        strWIDList[u32WidsCount].u16WIDid = WID_START_SCAN_REQ;
1345        strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
1346        strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
1347        strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrHostIFscanAttr->u8ScanSource));
1348        u32WidsCount++;
1349
1350        /*keep the state as is , no need to change it*/
1351        /* gWFiDrvHandle->enuHostIFstate = HOST_IF_SCANNING; */
1352
1353        if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED)
1354                gbScanWhileConnected = true;
1355        else if (pstrWFIDrv->enuHostIFstate == HOST_IF_IDLE)
1356                gbScanWhileConnected = false;
1357
1358        s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, false, (u32)pstrWFIDrv);
1359
1360        if (s32Error) {
1361                PRINT_ER("Failed to send scan paramters config packet\n");
1362                WILC_ERRORREPORT(s32Error, s32Error);
1363        } else {
1364                PRINT_D(HOSTINF_DBG, "Successfully sent SCAN params config packet\n");
1365        }
1366
1367        WILC_CATCH(s32Error)
1368        {
1369                del_timer(&pstrWFIDrv->hScanTimer);
1370                /*if there is an ongoing scan request*/
1371                Handle_ScanDone(drvHandler, SCAN_EVENT_ABORTED);
1372        }
1373
1374        /* Deallocate pstrHostIFscanAttr->u8ChnlListLen which was prevoisuly allocated by the sending thread */
1375        if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL) {
1376                kfree(pstrHostIFscanAttr->pu8ChnlFreqList);
1377                pstrHostIFscanAttr->pu8ChnlFreqList = NULL;
1378        }
1379
1380        /* Deallocate pstrHostIFscanAttr->pu8IEs which was previously allocated by the sending thread */
1381        if (pstrHostIFscanAttr->pu8IEs != NULL) {
1382                kfree(pstrHostIFscanAttr->pu8IEs);
1383                pstrHostIFscanAttr->pu8IEs = NULL;
1384        }
1385        if (pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo != NULL) {
1386                kfree(pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo);
1387                pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo = NULL;
1388        }
1389
1390        /* Deallocate pstrHostIFscanAttr->u8ChnlListLen which was prevoisuly allocated by the sending thread */
1391        if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL) {
1392                kfree(pstrHostIFscanAttr->pu8ChnlFreqList);
1393                pstrHostIFscanAttr->pu8ChnlFreqList = NULL;
1394        }
1395
1396        if (pu8HdnNtwrksWidVal != NULL)
1397                kfree(pu8HdnNtwrksWidVal);
1398
1399        return s32Error;
1400}
1401
1402/**
1403 *  @brief Handle_ScanDone
1404 *  @details       Call scan notification callback function
1405 *  @param[in]    NONE
1406 *  @return         Error code.
1407 *  @author
1408 *  @date
1409 *  @version    1.0
1410 */
1411static s32 Handle_ScanDone(tstrWILC_WFIDrv *drvHandler, tenuScanEvent enuEvent)
1412{
1413        s32 s32Error = WILC_SUCCESS;
1414
1415        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
1416
1417
1418        u8 u8abort_running_scan;
1419        tstrWID strWID;
1420
1421
1422        PRINT_D(HOSTINF_DBG, "in Handle_ScanDone()\n");
1423
1424        /*BugID_4978*/
1425        /*Ask FW to abort the running scan, if any*/
1426        if (enuEvent == SCAN_EVENT_ABORTED) {
1427                PRINT_D(GENERIC_DBG, "Abort running scan\n");
1428                u8abort_running_scan = 1;
1429                strWID.u16WIDid = (u16)WID_ABORT_RUNNING_SCAN;
1430                strWID.enuWIDtype       = WID_CHAR;
1431                strWID.ps8WidVal = (s8 *)&u8abort_running_scan;
1432                strWID.s32ValueSize = sizeof(char);
1433
1434                /*Sending Cfg*/
1435                s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
1436                if (s32Error != WILC_SUCCESS) {
1437                        PRINT_ER("Failed to set abort running scan\n");
1438                        WILC_ERRORREPORT(s32Error, WILC_FAIL);
1439                }
1440                WILC_CATCH(s32Error)
1441                {
1442                }
1443        }
1444
1445        if (pstrWFIDrv == NULL) {
1446                PRINT_ER("Driver handler is NULL\n");
1447                return s32Error;
1448        }
1449
1450        /*if there is an ongoing scan request*/
1451        if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
1452                pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(enuEvent, NULL,
1453                                                                pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
1454                /*delete current scan request*/
1455                pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
1456        }
1457
1458        return s32Error;
1459}
1460
1461/**
1462 *  @brief Handle_Connect
1463 *  @details       Sending config packet to firmware to starting connection
1464 *  @param[in]    tstrHostIFconnectAttr* pstrHostIFconnectAttr
1465 *  @return         Error code.
1466 *  @author
1467 *  @date
1468 *  @version    1.0
1469 */
1470u8 u8ConnectedSSID[6] = {0};
1471static s32 Handle_Connect(tstrWILC_WFIDrv *drvHandler, tstrHostIFconnectAttr *pstrHostIFconnectAttr)
1472{
1473        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
1474        s32 s32Error = WILC_SUCCESS;
1475        tstrWID strWIDList[8];
1476        u32 u32WidsCount = 0, dummyval = 0;
1477        /* char passphrase[] = "12345678"; */
1478        #ifndef CONNECT_DIRECT
1479        s32 s32Err = WILC_SUCCESS;
1480        u32 i;
1481        u8 u8bssDscListIndex;
1482        wid_site_survey_reslts_s *pstrSurveyResults = NULL;
1483        #else
1484        u8 *pu8CurrByte = NULL;
1485        /*Bug4218: Parsing Join Param*/
1486        #ifdef WILC_PARSE_SCAN_IN_HOST
1487        tstrJoinBssParam *ptstrJoinBssParam;
1488        #endif /*WILC_PARSE_SCAN_IN_HOST*/
1489
1490        #endif
1491
1492        PRINT_D(GENERIC_DBG, "Handling connect request\n");
1493
1494        #ifndef CONNECT_DIRECT
1495        memset(gapu8RcvdSurveyResults[0], 0, MAX_SURVEY_RESULT_FRAG_SIZE);
1496        memset(gapu8RcvdSurveyResults[1], 0, MAX_SURVEY_RESULT_FRAG_SIZE);
1497
1498
1499        PRINT_D(HOSTINF_DBG, "Getting site survey results\n");
1500        s32Err = host_int_get_site_survey_results(pstrWFIDrv,
1501                                                  gapu8RcvdSurveyResults,
1502                                                  MAX_SURVEY_RESULT_FRAG_SIZE);
1503        if (s32Err) {
1504                PRINT_ER("Failed to get site survey results\n");
1505                WILC_ERRORREPORT(s32Error, WILC_FAIL);
1506
1507        }
1508        s32Err = ParseSurveyResults(gapu8RcvdSurveyResults, &pstrSurveyResults,
1509                                    &pstrWFIDrv->u32SurveyResultsCount);
1510
1511
1512        if (s32Err == WILC_SUCCESS) {
1513                /* use the parsed info in pstrSurveyResults, then deallocate it */
1514                PRINT_D(HOSTINF_DBG, "Copying site survey results in global structure, then deallocate\n");
1515                for (i = 0; i < pstrWFIDrv->u32SurveyResultsCount; i++) {
1516                        memcpy(&pstrWFIDrv->astrSurveyResults[i], &pstrSurveyResults[i],
1517                                    sizeof(wid_site_survey_reslts_s));
1518                }
1519
1520                DeallocateSurveyResults(pstrSurveyResults);
1521        } else {
1522                WILC_ERRORREPORT(s32Error, WILC_FAIL);
1523                PRINT_ER("ParseSurveyResults() Error(%d)\n", s32Err);
1524        }
1525
1526
1527        for (i = 0; i < pstrWFIDrv->u32SurveyResultsCount; i++) {
1528                if (memcmp(pstrWFIDrv->astrSurveyResults[i].SSID,
1529                                pstrHostIFconnectAttr->pu8ssid,
1530                                pstrHostIFconnectAttr->ssidLen) == 0) {
1531                        PRINT_INFO(HOSTINF_DBG, "Network with required SSID is found %s\n", pstrHostIFconnectAttr->pu8ssid);
1532                        if (pstrHostIFconnectAttr->pu8bssid == NULL) {
1533                                /* BSSID is not passed from the user, so decision of matching
1534                                 * is done by SSID only */
1535                                PRINT_INFO(HOSTINF_DBG, "BSSID is not passed from the user\n");
1536                                break;
1537                        } else {
1538                                /* BSSID is also passed from the user, so decision of matching
1539                                 * should consider also this passed BSSID */
1540
1541                                if (memcmp(pstrWFIDrv->astrSurveyResults[i].BSSID,
1542                                                pstrHostIFconnectAttr->pu8bssid,
1543                                                6) == 0) {
1544                                        PRINT_INFO(HOSTINF_DBG, "BSSID is passed from the user and matched\n");
1545                                        break;
1546                                }
1547                        }
1548                }
1549        }
1550
1551        if (i < pstrWFIDrv->u32SurveyResultsCount) {
1552                u8bssDscListIndex = i;
1553
1554                PRINT_INFO(HOSTINF_DBG, "Connecting to network of Bss Idx%d and SSID %s and channel%d\n",
1555                           u8bssDscListIndex, pstrWFIDrv->astrSurveyResults[u8bssDscListIndex].SSID,
1556                           pstrWFIDrv->astrSurveyResults[u8bssDscListIndex].Channel);
1557
1558                PRINT_INFO(HOSTINF_DBG, "Saving connection parameters in global structure\n");
1559
1560                if (pstrHostIFconnectAttr->pu8bssid != NULL) {
1561                        pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = WILC_MALLOC(6);
1562                        memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
1563                }
1564
1565                pstrWFIDrv->strWILC_UsrConnReq.ssidLen = pstrHostIFconnectAttr->ssidLen;
1566                if (pstrHostIFconnectAttr->pu8ssid != NULL) {
1567                        pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = WILC_MALLOC(pstrHostIFconnectAttr->ssidLen + 1);
1568                        memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->pu8ssid,
1569                                    pstrHostIFconnectAttr->ssidLen);
1570                        pstrWFIDrv->strWILC_UsrConnReq.pu8ssid[pstrHostIFconnectAttr->ssidLen] = '\0';
1571                }
1572
1573                pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = pstrHostIFconnectAttr->IEsLen;
1574                if (pstrHostIFconnectAttr->pu8IEs != NULL) {
1575                        pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = WILC_MALLOC(pstrHostIFconnectAttr->IEsLen);
1576                        memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs, pstrHostIFconnectAttr->pu8IEs,
1577                                    pstrHostIFconnectAttr->IEsLen);
1578                }
1579
1580                pstrWFIDrv->strWILC_UsrConnReq.u8security = pstrHostIFconnectAttr->u8security;
1581                pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type = pstrHostIFconnectAttr->tenuAuth_type;
1582                pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult = pstrHostIFconnectAttr->pfConnectResult;
1583                pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid = pstrHostIFconnectAttr->pvUserArg;
1584
1585
1586                /* if((gWFiDrvHandle->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) && */
1587                /* (gWFiDrvHandle->strWILC_UsrConnReq.ConnReqIEsLen != 0)) */
1588                {
1589                        /* IEs to be inserted in Association Request */
1590                        strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_ASSOCIATE;
1591                        strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1592                        strWIDList[u32WidsCount].ps8WidVal = pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs;
1593                        strWIDList[u32WidsCount].s32ValueSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
1594                        u32WidsCount++;
1595                }
1596                strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE;
1597                strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
1598                strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
1599                strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrWFIDrv->strWILC_UsrConnReq.u8security));
1600                u32WidsCount++;
1601
1602                PRINT_INFO(HOSTINF_DBG, "Encrypt Mode = %x\n", pstrWFIDrv->strWILC_UsrConnReq.u8security);
1603
1604                strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE;
1605                strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
1606                strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
1607                strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
1608                u32WidsCount++;
1609
1610                PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n", pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
1611                /*
1612                 * strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_PSK;
1613                 * strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1614                 * strWIDList[u32WidsCount].s32ValueSize = sizeof(passphrase);
1615                 * strWIDList[u32WidsCount].ps8WidVal = (s8*)(passphrase);
1616                 * u32WidsCount++;
1617                 */
1618
1619                strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ;
1620                strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
1621                strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
1622                strWIDList[u32WidsCount].ps8WidVal = (s8 *)&u8bssDscListIndex;
1623                u32WidsCount++;
1624
1625                /* A temporary workaround to avoid handling the misleading MAC_DISCONNECTED raised from the
1626                 *   firmware at chip reset when processing the WIDs of the Connect Request.
1627                 *   (This workaround should be removed in the future when the Chip reset of the Connect WIDs is disabled) */
1628                /* ////////////////////// */
1629                gu32WidConnRstHack = 0;
1630                /* ////////////////////// */
1631
1632                s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, false, (u32)pstrWFIDrv);
1633                if (s32Error) {
1634                        PRINT_ER("Handle_Connect()] failed to send config packet\n");
1635                        WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
1636                } else {
1637                        pstrWFIDrv->enuHostIFstate = HOST_IF_WAITING_CONN_RESP;
1638                }
1639
1640        } else {
1641                PRINT_ER("Required BSSID not found\n");
1642                WILC_ERRORREPORT(s32Error, WILC_NOT_FOUND);
1643        }
1644
1645        #else
1646
1647        /* if we try to connect to an already connected AP then discard the request */
1648
1649        if (memcmp(pstrHostIFconnectAttr->pu8bssid, u8ConnectedSSID, ETH_ALEN) == 0) {
1650
1651                s32Error = WILC_SUCCESS;
1652                PRINT_ER("Trying to connect to an already connected AP, Discard connect request\n");
1653                return s32Error;
1654        }
1655
1656        PRINT_INFO(HOSTINF_DBG, "Saving connection parameters in global structure\n");
1657
1658        /*Bug4218: Parsing Join Param*/
1659        #ifdef WILC_PARSE_SCAN_IN_HOST
1660        ptstrJoinBssParam = (tstrJoinBssParam *)pstrHostIFconnectAttr->pJoinParams;
1661        if (ptstrJoinBssParam == NULL) {
1662                PRINT_ER("Required BSSID not found\n");
1663                WILC_ERRORREPORT(s32Error, WILC_NOT_FOUND);
1664        }
1665        #endif /*WILC_PARSE_SCAN_IN_HOST*/
1666
1667        if (pstrHostIFconnectAttr->pu8bssid != NULL) {
1668                pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = WILC_MALLOC(6);
1669                memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
1670        }
1671
1672        pstrWFIDrv->strWILC_UsrConnReq.ssidLen = pstrHostIFconnectAttr->ssidLen;
1673        if (pstrHostIFconnectAttr->pu8ssid != NULL) {
1674                pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = WILC_MALLOC(pstrHostIFconnectAttr->ssidLen + 1);
1675                memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->pu8ssid,
1676                            pstrHostIFconnectAttr->ssidLen);
1677                pstrWFIDrv->strWILC_UsrConnReq.pu8ssid[pstrHostIFconnectAttr->ssidLen] = '\0';
1678        }
1679
1680        pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = pstrHostIFconnectAttr->IEsLen;
1681        if (pstrHostIFconnectAttr->pu8IEs != NULL) {
1682                pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = WILC_MALLOC(pstrHostIFconnectAttr->IEsLen);
1683                memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs, pstrHostIFconnectAttr->pu8IEs,
1684                            pstrHostIFconnectAttr->IEsLen);
1685        }
1686
1687        pstrWFIDrv->strWILC_UsrConnReq.u8security = pstrHostIFconnectAttr->u8security;
1688        pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type = pstrHostIFconnectAttr->tenuAuth_type;
1689        pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult = pstrHostIFconnectAttr->pfConnectResult;
1690        pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid = pstrHostIFconnectAttr->pvUserArg;
1691
1692        strWIDList[u32WidsCount].u16WIDid = WID_SUCCESS_FRAME_COUNT;
1693        strWIDList[u32WidsCount].enuWIDtype = WID_INT;
1694        strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
1695        strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(dummyval));
1696        u32WidsCount++;
1697
1698        strWIDList[u32WidsCount].u16WIDid = WID_RECEIVED_FRAGMENT_COUNT;
1699        strWIDList[u32WidsCount].enuWIDtype = WID_INT;
1700        strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
1701        strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(dummyval));
1702        u32WidsCount++;
1703
1704        strWIDList[u32WidsCount].u16WIDid = WID_FAILED_COUNT;
1705        strWIDList[u32WidsCount].enuWIDtype = WID_INT;
1706        strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
1707        strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(dummyval));
1708        u32WidsCount++;
1709
1710        /* if((gWFiDrvHandle->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) && */
1711        /* (gWFiDrvHandle->strWILC_UsrConnReq.ConnReqIEsLen != 0)) */
1712        {
1713                /* IEs to be inserted in Association Request */
1714                strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_ASSOCIATE;
1715                strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1716                strWIDList[u32WidsCount].ps8WidVal = pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs;
1717                strWIDList[u32WidsCount].s32ValueSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
1718                u32WidsCount++;
1719
1720                /*BugID_5137*/
1721                if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
1722
1723                        gu32FlushedInfoElemAsocSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
1724                        gu8FlushedInfoElemAsoc =  WILC_MALLOC(gu32FlushedInfoElemAsocSize);
1725                        memcpy(gu8FlushedInfoElemAsoc, pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
1726                               gu32FlushedInfoElemAsocSize);
1727                }
1728        }
1729        strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE;
1730        strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
1731        strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
1732        strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrWFIDrv->strWILC_UsrConnReq.u8security));
1733        u32WidsCount++;
1734
1735        /*BugID_5137*/
1736        if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7))
1737                gu8Flushed11iMode = pstrWFIDrv->strWILC_UsrConnReq.u8security;
1738
1739        PRINT_INFO(HOSTINF_DBG, "Encrypt Mode = %x\n", pstrWFIDrv->strWILC_UsrConnReq.u8security);
1740
1741
1742        strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE;
1743        strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
1744        strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
1745        strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
1746        u32WidsCount++;
1747
1748        /*BugID_5137*/
1749        if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7))
1750                gu8FlushedAuthType = (u8)pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type;
1751
1752        PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n", pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
1753        /*
1754         * strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_PSK;
1755         * strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1756         * strWIDList[u32WidsCount].s32ValueSize = sizeof(passphrase);
1757         * strWIDList[u32WidsCount].ps8WidVal = (s8*)(passphrase);
1758         * u32WidsCount++;
1759         */
1760
1761        PRINT_D(HOSTINF_DBG, "Connecting to network of SSID %s on channel %d\n",
1762                pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->u8channel);
1763
1764
1765#ifndef WILC_PARSE_SCAN_IN_HOST
1766        strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ_EXTENDED;
1767        strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1768        strWIDList[u32WidsCount].s32ValueSize = MAX_SSID_LEN + 7;
1769        strWIDList[u32WidsCount].ps8WidVal = WILC_MALLOC(strWIDList[u32WidsCount].s32ValueSize);
1770
1771        if (strWIDList[u32WidsCount].ps8WidVal == NULL)
1772                WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
1773
1774        pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1775
1776        if (pstrHostIFconnectAttr->pu8ssid != NULL) {
1777                memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8ssid, pstrHostIFconnectAttr->ssidLen);
1778                pu8CurrByte[pstrHostIFconnectAttr->ssidLen] = '\0';
1779        }
1780        pu8CurrByte += MAX_SSID_LEN;
1781        if ((pstrHostIFconnectAttr->u8channel >= 1) && (pstrHostIFconnectAttr->u8channel <= 14)) {
1782                *(pu8CurrByte++) = pstrHostIFconnectAttr->u8channel;
1783        } else {
1784                PRINT_ER("Channel out of range\n");
1785                *(pu8CurrByte++) = 0xFF;
1786        }
1787        if (pstrHostIFconnectAttr->pu8bssid != NULL)
1788                memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
1789        pu8CurrByte += 6;
1790
1791        /* keep the buffer at the start of the allocated pointer to use it with the free*/
1792        pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1793
1794        #else
1795
1796        strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ_EXTENDED;
1797        strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1798
1799        /*Sending NoA attributes during connection*/
1800        strWIDList[u32WidsCount].s32ValueSize = 112; /* 79; */
1801        strWIDList[u32WidsCount].ps8WidVal = WILC_MALLOC(strWIDList[u32WidsCount].s32ValueSize);
1802
1803        /*BugID_5137*/
1804        if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
1805                gu32FlushedJoinReqSize = strWIDList[u32WidsCount].s32ValueSize;
1806                gu8FlushedJoinReq = WILC_MALLOC(gu32FlushedJoinReqSize);
1807        }
1808        if (strWIDList[u32WidsCount].ps8WidVal == NULL)
1809                WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
1810
1811        pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1812
1813
1814        if (pstrHostIFconnectAttr->pu8ssid != NULL) {
1815                memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8ssid, pstrHostIFconnectAttr->ssidLen);
1816                pu8CurrByte[pstrHostIFconnectAttr->ssidLen] = '\0';
1817        }
1818        pu8CurrByte += MAX_SSID_LEN;
1819
1820        /* BSS type*/
1821        *(pu8CurrByte++) = INFRASTRUCTURE;
1822        /* Channel*/
1823        if ((pstrHostIFconnectAttr->u8channel >= 1) && (pstrHostIFconnectAttr->u8channel <= 14)) {
1824                *(pu8CurrByte++) = pstrHostIFconnectAttr->u8channel;
1825        } else {
1826                PRINT_ER("Channel out of range\n");
1827                *(pu8CurrByte++) = 0xFF;
1828        }
1829        /* Cap Info*/
1830        *(pu8CurrByte++)  = (ptstrJoinBssParam->cap_info) & 0xFF;
1831        *(pu8CurrByte++)  = ((ptstrJoinBssParam->cap_info) >> 8) & 0xFF;
1832        PRINT_D(HOSTINF_DBG, "* Cap Info %0x*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1833
1834        /* sa*/
1835        if (pstrHostIFconnectAttr->pu8bssid != NULL)
1836                memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
1837        pu8CurrByte += 6;
1838
1839        /* bssid*/
1840        if (pstrHostIFconnectAttr->pu8bssid != NULL)
1841                memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
1842        pu8CurrByte += 6;
1843
1844        /* Beacon Period*/
1845        *(pu8CurrByte++)  = (ptstrJoinBssParam->beacon_period) & 0xFF;
1846        *(pu8CurrByte++)  = ((ptstrJoinBssParam->beacon_period) >> 8) & 0xFF;
1847        PRINT_D(HOSTINF_DBG, "* Beacon Period %d*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1848        /* DTIM Period*/
1849        *(pu8CurrByte++)  =  ptstrJoinBssParam->dtim_period;
1850        PRINT_D(HOSTINF_DBG, "* DTIM Period %d*\n", (*(pu8CurrByte - 1)));
1851        /* Supported rates*/
1852        memcpy(pu8CurrByte, ptstrJoinBssParam->supp_rates, MAX_RATES_SUPPORTED + 1);
1853        pu8CurrByte += (MAX_RATES_SUPPORTED + 1);
1854
1855        /* wmm cap*/
1856        *(pu8CurrByte++)  =  ptstrJoinBssParam->wmm_cap;
1857        PRINT_D(HOSTINF_DBG, "* wmm cap%d*\n", (*(pu8CurrByte - 1)));
1858        /* uapsd cap*/
1859        *(pu8CurrByte++)  = ptstrJoinBssParam->uapsd_cap;
1860
1861        /* ht cap*/
1862        *(pu8CurrByte++)  = ptstrJoinBssParam->ht_capable;
1863        /* copy this information to the user request */
1864        pstrWFIDrv->strWILC_UsrConnReq.IsHTCapable = ptstrJoinBssParam->ht_capable;
1865
1866        /* rsn found*/
1867        *(pu8CurrByte++)  =  ptstrJoinBssParam->rsn_found;
1868        PRINT_D(HOSTINF_DBG, "* rsn found %d*\n", *(pu8CurrByte - 1));
1869        /* rsn group policy*/
1870        *(pu8CurrByte++)  =  ptstrJoinBssParam->rsn_grp_policy;
1871        PRINT_D(HOSTINF_DBG, "* rsn group policy %0x*\n", (*(pu8CurrByte - 1)));
1872        /* mode_802_11i*/
1873        *(pu8CurrByte++) =  ptstrJoinBssParam->mode_802_11i;
1874        PRINT_D(HOSTINF_DBG, "* mode_802_11i %d*\n", (*(pu8CurrByte - 1)));
1875        /* rsn pcip policy*/
1876        memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_pcip_policy, sizeof(ptstrJoinBssParam->rsn_pcip_policy));
1877        pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_pcip_policy);
1878
1879        /* rsn auth policy*/
1880        memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_auth_policy, sizeof(ptstrJoinBssParam->rsn_auth_policy));
1881        pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_auth_policy);
1882
1883        /* rsn auth policy*/
1884        memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_cap, sizeof(ptstrJoinBssParam->rsn_cap));
1885        pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_cap);
1886
1887        /*BugID_5137*/
1888        *(pu8CurrByte++) = REAL_JOIN_REQ;
1889
1890                #ifdef WILC_P2P
1891        *(pu8CurrByte++) = ptstrJoinBssParam->u8NoaEnbaled;
1892        if (ptstrJoinBssParam->u8NoaEnbaled) {
1893                PRINT_D(HOSTINF_DBG, "NOA present\n");
1894
1895                *(pu8CurrByte++) = (ptstrJoinBssParam->tsf) & 0xFF;
1896                *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 8) & 0xFF;
1897                *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 16) & 0xFF;
1898                *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 24) & 0xFF;
1899
1900                *(pu8CurrByte++) = ptstrJoinBssParam->u8Index;
1901
1902                *(pu8CurrByte++) = ptstrJoinBssParam->u8OppEnable;
1903
1904                if (ptstrJoinBssParam->u8OppEnable)
1905                        *(pu8CurrByte++) = ptstrJoinBssParam->u8CtWindow;
1906
1907                *(pu8CurrByte++) = ptstrJoinBssParam->u8Count;
1908
1909                memcpy(pu8CurrByte, ptstrJoinBssParam->au8Duration, sizeof(ptstrJoinBssParam->au8Duration));
1910
1911                pu8CurrByte += sizeof(ptstrJoinBssParam->au8Duration);
1912
1913                memcpy(pu8CurrByte, ptstrJoinBssParam->au8Interval, sizeof(ptstrJoinBssParam->au8Interval));
1914
1915                pu8CurrByte += sizeof(ptstrJoinBssParam->au8Interval);
1916
1917                memcpy(pu8CurrByte, ptstrJoinBssParam->au8StartTime, sizeof(ptstrJoinBssParam->au8StartTime));
1918
1919                pu8CurrByte += sizeof(ptstrJoinBssParam->au8StartTime);
1920
1921        } else
1922                PRINT_D(HOSTINF_DBG, "NOA not present\n");
1923        #endif
1924
1925
1926        /* keep the buffer at the start of the allocated pointer to use it with the free*/
1927        pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1928
1929
1930        #endif /* #ifdef WILC_PARSE_SCAN_IN_HOST*/
1931        u32WidsCount++;
1932
1933        /* A temporary workaround to avoid handling the misleading MAC_DISCONNECTED raised from the
1934         *   firmware at chip reset when processing the WIDs of the Connect Request.
1935         *   (This workaround should be removed in the future when the Chip reset of the Connect WIDs is disabled) */
1936        /* ////////////////////// */
1937        gu32WidConnRstHack = 0;
1938        /* ////////////////////// */
1939
1940        /*BugID_5137*/
1941        if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
1942                memcpy(gu8FlushedJoinReq, pu8CurrByte, gu32FlushedJoinReqSize);
1943                gu8FlushedJoinReqDrvHandler = (u32)pstrWFIDrv;
1944        }
1945
1946        PRINT_D(GENERIC_DBG, "send HOST_IF_WAITING_CONN_RESP\n");
1947
1948        if (pstrHostIFconnectAttr->pu8bssid != NULL) {
1949                memcpy(u8ConnectedSSID, pstrHostIFconnectAttr->pu8bssid, ETH_ALEN);
1950
1951                PRINT_D(GENERIC_DBG, "save Bssid = %x:%x:%x:%x:%x:%x\n", (pstrHostIFconnectAttr->pu8bssid[0]), (pstrHostIFconnectAttr->pu8bssid[1]), (pstrHostIFconnectAttr->pu8bssid[2]), (pstrHostIFconnectAttr->pu8bssid[3]), (pstrHostIFconnectAttr->pu8bssid[4]), (pstrHostIFconnectAttr->pu8bssid[5]));
1952                PRINT_D(GENERIC_DBG, "save bssid = %x:%x:%x:%x:%x:%x\n", (u8ConnectedSSID[0]), (u8ConnectedSSID[1]), (u8ConnectedSSID[2]), (u8ConnectedSSID[3]), (u8ConnectedSSID[4]), (u8ConnectedSSID[5]));
1953        }
1954
1955        s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, false, (u32)pstrWFIDrv);
1956        if (s32Error) {
1957                PRINT_ER("Handle_Connect()] failed to send config packet\n");
1958                WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
1959        } else {
1960                PRINT_D(GENERIC_DBG, "set HOST_IF_WAITING_CONN_RESP\n");
1961                pstrWFIDrv->enuHostIFstate = HOST_IF_WAITING_CONN_RESP;
1962        }
1963        #endif
1964
1965        WILC_CATCH(s32Error)
1966        {
1967                tstrConnectInfo strConnectInfo;
1968
1969                del_timer(&pstrWFIDrv->hConnectTimer);
1970
1971                PRINT_D(HOSTINF_DBG, "could not start connecting to the required network\n");
1972
1973                memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
1974
1975                if (pstrHostIFconnectAttr->pfConnectResult != NULL) {
1976                        if (pstrHostIFconnectAttr->pu8bssid != NULL)
1977                                memcpy(strConnectInfo.au8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
1978
1979                        if (pstrHostIFconnectAttr->pu8IEs != NULL) {
1980                                strConnectInfo.ReqIEsLen = pstrHostIFconnectAttr->IEsLen;
1981                                strConnectInfo.pu8ReqIEs = WILC_MALLOC(pstrHostIFconnectAttr->IEsLen);
1982                                memcpy(strConnectInfo.pu8ReqIEs,
1983                                            pstrHostIFconnectAttr->pu8IEs,
1984                                            pstrHostIFconnectAttr->IEsLen);
1985                        }
1986
1987                        pstrHostIFconnectAttr->pfConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
1988                                                               &strConnectInfo,
1989                                                               MAC_DISCONNECTED,
1990                                                               NULL,
1991                                                               pstrHostIFconnectAttr->pvUserArg);
1992                        /*Change state to idle*/
1993                        pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
1994                        /* Deallocation */
1995                        if (strConnectInfo.pu8ReqIEs != NULL) {
1996                                kfree(strConnectInfo.pu8ReqIEs);
1997                                strConnectInfo.pu8ReqIEs = NULL;
1998                        }
1999
2000                } else {
2001                        PRINT_ER("Connect callback function pointer is NULL\n");
2002                }
2003        }
2004
2005        PRINT_D(HOSTINF_DBG, "Deallocating connection parameters\n");
2006        /* Deallocate pstrHostIFconnectAttr->pu8bssid which was prevoisuly allocated by the sending thread */
2007        if (pstrHostIFconnectAttr->pu8bssid != NULL) {
2008                kfree(pstrHostIFconnectAttr->pu8bssid);
2009                pstrHostIFconnectAttr->pu8bssid = NULL;
2010        }
2011
2012        /* Deallocate pstrHostIFconnectAttr->pu8ssid which was prevoisuly allocated by the sending thread */
2013        if (pstrHostIFconnectAttr->pu8ssid != NULL) {
2014                kfree(pstrHostIFconnectAttr->pu8ssid);
2015                pstrHostIFconnectAttr->pu8ssid = NULL;
2016        }
2017
2018        /* Deallocate pstrHostIFconnectAttr->pu8IEs which was prevoisuly allocated by the sending thread */
2019        if (pstrHostIFconnectAttr->pu8IEs != NULL) {
2020                kfree(pstrHostIFconnectAttr->pu8IEs);
2021                pstrHostIFconnectAttr->pu8IEs = NULL;
2022        }
2023
2024        if (pu8CurrByte != NULL)
2025                kfree(pu8CurrByte);
2026        return s32Error;
2027}
2028
2029/**
2030 *  @brief                      Handle_FlushConnect
2031 *  @details            Sending config packet to firmware to flush an old connection
2032 *                              after switching FW from station one to hybrid one
2033 *  @param[in]          void * drvHandler
2034 *  @return             Error code.
2035 *  @author             Amr Abdel-Moghny
2036 *  @date                       19 DEC 2013
2037 *  @version            8.0
2038 */
2039
2040static s32 Handle_FlushConnect(tstrWILC_WFIDrv *drvHandler)
2041{
2042        s32 s32Error = WILC_SUCCESS;
2043        tstrWID strWIDList[5];
2044        u32 u32WidsCount = 0;
2045        u8 *pu8CurrByte = NULL;
2046
2047
2048        /* IEs to be inserted in Association Request */
2049        strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_ASSOCIATE;
2050        strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
2051        strWIDList[u32WidsCount].ps8WidVal = gu8FlushedInfoElemAsoc;
2052        strWIDList[u32WidsCount].s32ValueSize = gu32FlushedInfoElemAsocSize;
2053        u32WidsCount++;
2054
2055        strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE;
2056        strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
2057        strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
2058        strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(gu8Flushed11iMode));
2059        u32WidsCount++;
2060
2061
2062
2063        strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE;
2064        strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
2065        strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
2066        strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&gu8FlushedAuthType);
2067        u32WidsCount++;
2068
2069
2070        #ifdef WILC_PARSE_SCAN_IN_HOST
2071        strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ_EXTENDED;
2072        strWIDList[u32WidsCount].enuWIDtype = WID_STR;
2073        strWIDList[u32WidsCount].s32ValueSize = gu32FlushedJoinReqSize;
2074        strWIDList[u32WidsCount].ps8WidVal = (s8 *)gu8FlushedJoinReq;
2075        pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
2076
2077        pu8CurrByte += FLUSHED_BYTE_POS;
2078        *(pu8CurrByte) = FLUSHED_JOIN_REQ;
2079
2080        u32WidsCount++;
2081
2082        #endif
2083
2084        s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, false, gu8FlushedJoinReqDrvHandler);
2085        if (s32Error) {
2086                PRINT_ER("Handle_Flush_Connect()] failed to send config packet\n");
2087                WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
2088        }
2089
2090        WILC_CATCH(s32Error)
2091        {
2092
2093        }
2094
2095        return s32Error;
2096}
2097
2098/**
2099 *  @brief                 Handle_ConnectTimeout
2100 *  @details       Call connect notification callback function indicating connection failure
2101 *  @param[in]    NONE
2102 *  @return         Error code.
2103 *  @author
2104 *  @date
2105 *  @version    1.0
2106 */
2107static s32 Handle_ConnectTimeout(tstrWILC_WFIDrv *drvHandler)
2108{
2109        s32 s32Error = WILC_SUCCESS;
2110        tstrConnectInfo strConnectInfo;
2111        tstrWID strWID;
2112        u16 u16DummyReasonCode = 0;
2113        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
2114
2115        if (pstrWFIDrv == NULL) {
2116                PRINT_ER("Driver handler is NULL\n");
2117                return s32Error;
2118        }
2119
2120        pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
2121
2122        gbScanWhileConnected = false;
2123
2124
2125        memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
2126
2127
2128        /* First, we will notify the upper layer with the Connection failure {through the Connect Callback function},
2129         *   then we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying
2130         *   WID_DISCONNECT} */
2131        if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
2132                if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
2133                        memcpy(strConnectInfo.au8bssid,
2134                                    pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, 6);
2135                }
2136
2137                if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2138                        strConnectInfo.ReqIEsLen = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
2139                        strConnectInfo.pu8ReqIEs = WILC_MALLOC(pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
2140                        memcpy(strConnectInfo.pu8ReqIEs,
2141                                    pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
2142                                    pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
2143                }
2144
2145                pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
2146                                                                   &strConnectInfo,
2147                                                                   MAC_DISCONNECTED,
2148                                                                   NULL,
2149                                                                   pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
2150
2151                /* Deallocation of strConnectInfo.pu8ReqIEs */
2152                if (strConnectInfo.pu8ReqIEs != NULL) {
2153                        kfree(strConnectInfo.pu8ReqIEs);
2154                        strConnectInfo.pu8ReqIEs = NULL;
2155                }
2156        } else {
2157                PRINT_ER("Connect callback function pointer is NULL\n");
2158        }
2159
2160        /* Here we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying
2161         *   WID_DISCONNECT} */
2162        strWID.u16WIDid = (u16)WID_DISCONNECT;
2163        strWID.enuWIDtype = WID_CHAR;
2164        strWID.ps8WidVal = (s8 *)&u16DummyReasonCode;
2165        strWID.s32ValueSize = sizeof(char);
2166
2167        PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
2168
2169        s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv);
2170        if (s32Error)
2171                PRINT_ER("Failed to send dissconect config packet\n");
2172
2173        /* Deallocation of the Saved Connect Request in the global Handle */
2174        pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
2175        if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
2176                kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
2177                pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
2178        }
2179
2180        if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
2181                kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
2182                pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
2183        }
2184
2185        pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2186        if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2187                kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
2188                pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
2189        }
2190
2191        memset(u8ConnectedSSID, 0, ETH_ALEN);
2192        /*BugID_5213*/
2193        /*Freeing flushed join request params on connect timeout*/
2194        if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == (u32)drvHandler) {
2195                kfree(gu8FlushedJoinReq);
2196                gu8FlushedJoinReq = NULL;
2197        }
2198        if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == (u32)drvHandler) {
2199                kfree(gu8FlushedInfoElemAsoc);
2200                gu8FlushedInfoElemAsoc = NULL;
2201        }
2202
2203        return s32Error;
2204}
2205
2206/**
2207 *  @brief Handle_RcvdNtwrkInfo
2208 *  @details       Handling received network information
2209 *  @param[in]    tstrRcvdNetworkInfo* pstrRcvdNetworkInfo
2210 *  @return         Error code.
2211 *  @author
2212 *  @date
2213 *  @version    1.0
2214 */
2215static s32 Handle_RcvdNtwrkInfo(tstrWILC_WFIDrv *drvHandler, tstrRcvdNetworkInfo *pstrRcvdNetworkInfo)
2216{
2217        u32 i;
2218        bool bNewNtwrkFound;
2219
2220
2221
2222        s32 s32Error = WILC_SUCCESS;
2223        tstrNetworkInfo *pstrNetworkInfo = NULL;
2224        void *pJoinParams = NULL;
2225
2226        tstrWILC_WFIDrv *pstrWFIDrv  = (tstrWILC_WFIDrv *)drvHandler;
2227
2228
2229
2230        bNewNtwrkFound = true;
2231        PRINT_INFO(HOSTINF_DBG, "Handling received network info\n");
2232
2233        /*if there is a an ongoing scan request*/
2234        if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
2235                PRINT_D(HOSTINF_DBG, "State: Scanning, parsing network information received\n");
2236                ParseNetworkInfo(pstrRcvdNetworkInfo->pu8Buffer, &pstrNetworkInfo);
2237                if ((pstrNetworkInfo == NULL)
2238                    || (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult == NULL)) {
2239                        WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
2240                }
2241
2242                /* check whether this network is discovered before */
2243                for (i = 0; i < pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount; i++) {
2244
2245                        if ((pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid != NULL) &&
2246                            (pstrNetworkInfo->au8bssid != NULL)) {
2247                                if (memcmp(pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid,
2248                                                pstrNetworkInfo->au8bssid, 6) == 0) {
2249                                        if (pstrNetworkInfo->s8rssi <= pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi) {
2250                                                /*we have already found this network with better rssi, so keep the old cached one and don't
2251                                                 *  send anything to the upper layer */
2252                                                PRINT_D(HOSTINF_DBG, "Network previously discovered\n");
2253                                                goto done;
2254                                        } else {
2255                                                /* here the same already found network is found again but with a better rssi, so just update
2256                                                 *   the rssi for this cached network and send this updated network to the upper layer but
2257                                                 *   don't add a new record for it */
2258                                                pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi = pstrNetworkInfo->s8rssi;
2259                                                bNewNtwrkFound = false;
2260                                                break;
2261                                        }
2262                                }
2263                        }
2264                }
2265
2266                if (bNewNtwrkFound == true) {
2267                        /* here it is confirmed that it is a new discovered network,
2268                         * so add its record then call the User CallBack function */
2269
2270                        PRINT_D(HOSTINF_DBG, "New network found\n");
2271
2272                        if (pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) {
2273                                pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].s8rssi = pstrNetworkInfo->s8rssi;
2274
2275                                if ((pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid != NULL)
2276                                    && (pstrNetworkInfo->au8bssid != NULL)) {
2277                                        memcpy(pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid,
2278                                                    pstrNetworkInfo->au8bssid, 6);
2279
2280                                        pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount++;
2281
2282                                        pstrNetworkInfo->bNewNetwork = true;
2283                                        /*Bug4218: Parsing Join Param*/
2284                                        /* add new BSS to JoinBssTable */
2285                                #ifdef WILC_PARSE_SCAN_IN_HOST
2286                                        pJoinParams = host_int_ParseJoinBssParam(pstrNetworkInfo);
2287                                #endif /*WILC_PARSE_SCAN_IN_HOST*/
2288
2289                                        pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
2290                                                                                        pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid,
2291                                                                                        pJoinParams);
2292
2293
2294                                }
2295                        } else {
2296                                PRINT_WRN(HOSTINF_DBG, "Discovered networks exceeded max. limit\n");
2297                        }
2298                } else {
2299                        pstrNetworkInfo->bNewNetwork = false;
2300                        /* just call the User CallBack function to send the same discovered network with its updated RSSI */
2301                        pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
2302                                                                        pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
2303                }
2304        }
2305
2306
2307        WILC_CATCH(s32Error)
2308        {
2309
2310        }
2311
2312done:
2313        /* Deallocate pstrRcvdNetworkInfo->pu8Buffer which was prevoisuly allocated by the sending thread */
2314        if (pstrRcvdNetworkInfo->pu8Buffer != NULL) {
2315                kfree(pstrRcvdNetworkInfo->pu8Buffer);
2316                pstrRcvdNetworkInfo->pu8Buffer = NULL;
2317        }
2318
2319        /*free structure allocated*/
2320        if (pstrNetworkInfo != NULL) {
2321                DeallocateNetworkInfo(pstrNetworkInfo);
2322                pstrNetworkInfo = NULL;
2323        }
2324
2325        return s32Error;
2326}
2327
2328/**
2329 *  @brief Handle_RcvdGnrlAsyncInfo
2330 *  @details       Handling received asynchrous general network information
2331 *  @param[in]    tstrRcvdGnrlAsyncInfo* pstrRcvdGnrlAsyncInfo
2332 *  @return         Error code.
2333 *  @author
2334 *  @date
2335 *  @version    1.0
2336 */
2337static s32 Handle_RcvdGnrlAsyncInfo(tstrWILC_WFIDrv *drvHandler, tstrRcvdGnrlAsyncInfo *pstrRcvdGnrlAsyncInfo)
2338{
2339        /* TODO: mostafa: till now, this function just handles only the received mac status msg, */
2340        /*                               which carries only 1 WID which have WID ID = WID_STATUS */
2341        s32 s32Error = WILC_SUCCESS;
2342        u8 u8MsgType = 0;
2343        u8 u8MsgID = 0;
2344        u16 u16MsgLen = 0;
2345        u16 u16WidID = (u16)WID_NIL;
2346        u8 u8WidLen  = 0;
2347        u8 u8MacStatus;
2348        u8 u8MacStatusReasonCode;
2349        u8 u8MacStatusAdditionalInfo;
2350        tstrConnectInfo strConnectInfo;
2351        tstrDisconnectNotifInfo strDisconnectNotifInfo;
2352        s32 s32Err = WILC_SUCCESS;
2353        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
2354
2355        if (pstrWFIDrv == NULL)
2356                PRINT_ER("Driver handler is NULL\n");
2357        PRINT_D(GENERIC_DBG, "Current State = %d,Received state = %d\n", pstrWFIDrv->enuHostIFstate,
2358                pstrRcvdGnrlAsyncInfo->pu8Buffer[7]);
2359
2360        if ((pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) ||
2361            (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) ||
2362            pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
2363                if ((pstrRcvdGnrlAsyncInfo->pu8Buffer == NULL) ||
2364                    (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult == NULL)) {
2365                        WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
2366                }
2367
2368                u8MsgType = pstrRcvdGnrlAsyncInfo->pu8Buffer[0];
2369
2370                /* Check whether the received message type is 'I' */
2371                if ('I' != u8MsgType) {
2372                        PRINT_ER("Received Message format incorrect.\n");
2373                        WILC_ERRORREPORT(s32Error, WILC_FAIL);
2374                }
2375
2376                /* Extract message ID */
2377                u8MsgID = pstrRcvdGnrlAsyncInfo->pu8Buffer[1];
2378
2379                /* Extract message Length */
2380                u16MsgLen = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->pu8Buffer[2], pstrRcvdGnrlAsyncInfo->pu8Buffer[3]);
2381
2382                /* Extract WID ID [expected to be = WID_STATUS] */
2383                u16WidID = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->pu8Buffer[4], pstrRcvdGnrlAsyncInfo->pu8Buffer[5]);
2384
2385                /* Extract WID Length [expected to be = 1] */
2386                u8WidLen = pstrRcvdGnrlAsyncInfo->pu8Buffer[6];
2387
2388                /* get the WID value [expected to be one of two values: either MAC_CONNECTED = (1) or MAC_DISCONNECTED = (0)] */
2389                u8MacStatus  = pstrRcvdGnrlAsyncInfo->pu8Buffer[7];
2390                u8MacStatusReasonCode = pstrRcvdGnrlAsyncInfo->pu8Buffer[8];
2391                u8MacStatusAdditionalInfo = pstrRcvdGnrlAsyncInfo->pu8Buffer[9];
2392                PRINT_INFO(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Info = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
2393                if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
2394                        /* our station had sent Association Request frame, so here it will get the Association Response frame then parse it */
2395                        u32 u32RcvdAssocRespInfoLen;
2396                        tstrConnectRespInfo *pstrConnectRespInfo = NULL;
2397
2398                        PRINT_D(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Code = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
2399
2400                        memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
2401
2402                        if (u8MacStatus == MAC_CONNECTED) {
2403                                memset(gapu8RcvdAssocResp, 0, MAX_ASSOC_RESP_FRAME_SIZE);
2404
2405                                host_int_get_assoc_res_info(pstrWFIDrv,
2406                                                            gapu8RcvdAssocResp,
2407                                                            MAX_ASSOC_RESP_FRAME_SIZE,
2408                                                            &u32RcvdAssocRespInfoLen);
2409
2410                                PRINT_INFO(HOSTINF_DBG, "Received association response with length = %d\n", u32RcvdAssocRespInfoLen);
2411
2412                                if (u32RcvdAssocRespInfoLen != 0) {
2413
2414                                        PRINT_D(HOSTINF_DBG, "Parsing association response\n");
2415                                        s32Err = ParseAssocRespInfo(gapu8RcvdAssocResp, u32RcvdAssocRespInfoLen,
2416                                                                    &pstrConnectRespInfo);
2417                                        if (s32Err) {
2418                                                PRINT_ER("ParseAssocRespInfo() returned error %d\n", s32Err);
2419                                        } else {
2420                                                /* use the necessary parsed Info from the Received Association Response */
2421                                                strConnectInfo.u16ConnectStatus = pstrConnectRespInfo->u16ConnectStatus;
2422
2423                                                if (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE) {
2424                                                        PRINT_INFO(HOSTINF_DBG, "Association response received : Successful connection status\n");
2425                                                        if (pstrConnectRespInfo->pu8RespIEs != NULL) {
2426                                                                strConnectInfo.u16RespIEsLen = pstrConnectRespInfo->u16RespIEsLen;
2427
2428
2429                                                                strConnectInfo.pu8RespIEs = WILC_MALLOC(pstrConnectRespInfo->u16RespIEsLen);
2430                                                                memcpy(strConnectInfo.pu8RespIEs, pstrConnectRespInfo->pu8RespIEs,
2431                                                                            pstrConnectRespInfo->u16RespIEsLen);
2432                                                        }
2433                                                }
2434
2435                                                /* deallocate the Assoc. Resp. parsed structure as it is not needed anymore */
2436                                                if (pstrConnectRespInfo != NULL) {
2437                                                        DeallocateAssocRespInfo(pstrConnectRespInfo);
2438                                                        pstrConnectRespInfo = NULL;
2439                                                }
2440                                        }
2441                                }
2442                        }
2443
2444                        /* The station has just received mac status and it also received assoc. response which
2445                         *   it was waiting for.
2446                         *   So check first the matching between the received mac status and the received status code in Asoc Resp */
2447                        if ((u8MacStatus == MAC_CONNECTED) &&
2448                            (strConnectInfo.u16ConnectStatus != SUCCESSFUL_STATUSCODE)) {
2449                                PRINT_ER("Received MAC status is MAC_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE\n");
2450                                memset(u8ConnectedSSID, 0, ETH_ALEN);
2451
2452                        } else if (u8MacStatus == MAC_DISCONNECTED)    {
2453                                PRINT_ER("Received MAC status is MAC_DISCONNECTED\n");
2454                                memset(u8ConnectedSSID, 0, ETH_ALEN);
2455                        }
2456
2457                        /* TODO: mostafa: correct BSSID should be retrieved from actual BSSID received from AP */
2458                        /*               through a structure of type tstrConnectRespInfo */
2459                        if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
2460                                PRINT_D(HOSTINF_DBG, "Retrieving actual BSSID from AP\n");
2461                                memcpy(strConnectInfo.au8bssid, pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, 6);
2462
2463                                if ((u8MacStatus == MAC_CONNECTED) &&
2464                                    (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
2465                                        memcpy(pstrWFIDrv->au8AssociatedBSSID,
2466                                                    pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, ETH_ALEN);
2467                                }
2468                        }
2469
2470
2471                        if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2472                                strConnectInfo.ReqIEsLen = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
2473                                strConnectInfo.pu8ReqIEs = WILC_MALLOC(pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
2474                                memcpy(strConnectInfo.pu8ReqIEs,
2475                                            pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
2476                                            pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
2477                        }
2478
2479
2480                        del_timer(&pstrWFIDrv->hConnectTimer);
2481                        pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
2482                                                                           &strConnectInfo,
2483                                                                           u8MacStatus,
2484                                                                           NULL,
2485                                                                           pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
2486
2487
2488                        /* if received mac status is MAC_CONNECTED and
2489                         *  received status code in Asoc Resp is SUCCESSFUL_STATUSCODE, change state to CONNECTED
2490                         *  else change state to IDLE */
2491                        if ((u8MacStatus == MAC_CONNECTED) &&
2492                            (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
2493                                #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2494
2495                                host_int_set_power_mgmt(pstrWFIDrv, 0, 0);
2496                                #endif
2497
2498                                PRINT_D(HOSTINF_DBG, "MAC status : CONNECTED and Connect Status : Successful\n");
2499                                pstrWFIDrv->enuHostIFstate = HOST_IF_CONNECTED;
2500
2501                                #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2502                                PRINT_D(GENERIC_DBG, "Obtaining an IP, Disable Scan\n");
2503                                g_obtainingIP = true;
2504                                mod_timer(&hDuringIpTimer,
2505                                          jiffies + msecs_to_jiffies(10000));
2506                                #endif
2507
2508                                #ifdef WILC_PARSE_SCAN_IN_HOST
2509                                /* open a BA session if possible */
2510                                /* if(pstrWFIDrv->strWILC_UsrConnReq.IsHTCapable) */
2511
2512                                #endif
2513
2514                                /* host_int_addBASession(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid,0, */
2515                                /* BA_SESSION_DEFAULT_BUFFER_SIZE,BA_SESSION_DEFAULT_TIMEOUT); */
2516                        } else {
2517                                PRINT_D(HOSTINF_DBG, "MAC status : %d and Connect Status : %d\n", u8MacStatus, strConnectInfo.u16ConnectStatus);
2518                                pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
2519                                gbScanWhileConnected = false;
2520                        }
2521
2522                        /* Deallocation */
2523                        if (strConnectInfo.pu8RespIEs != NULL) {
2524                                kfree(strConnectInfo.pu8RespIEs);
2525                                strConnectInfo.pu8RespIEs = NULL;
2526                        }
2527
2528                        if (strConnectInfo.pu8ReqIEs != NULL) {
2529                                kfree(strConnectInfo.pu8ReqIEs);
2530                                strConnectInfo.pu8ReqIEs = NULL;
2531                        }
2532
2533
2534                        pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
2535                        if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
2536                                kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
2537                                pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
2538                        }
2539
2540                        if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
2541                                kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
2542                                pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
2543                        }
2544
2545                        pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2546                        if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2547                                kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
2548                                pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
2549                        }
2550
2551                } else if ((u8MacStatus == MAC_DISCONNECTED) &&
2552                           (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED)) {
2553                        /* Disassociation or Deauthentication frame has been received */
2554                        PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW\n");
2555
2556                        memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
2557
2558                        if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
2559                                PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running OBSS Scan >>\n\n");
2560                                del_timer(&pstrWFIDrv->hScanTimer);
2561                                Handle_ScanDone((void *)pstrWFIDrv, SCAN_EVENT_ABORTED);
2562                        }
2563
2564                        strDisconnectNotifInfo.u16reason = 0;
2565                        strDisconnectNotifInfo.ie = NULL;
2566                        strDisconnectNotifInfo.ie_len = 0;
2567
2568                        if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
2569                                #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2570
2571                                g_obtainingIP = false;
2572                                host_int_set_power_mgmt(pstrWFIDrv, 0, 0);
2573                                #endif
2574
2575                                pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF,
2576                                                                                   NULL,
2577                                                                                   0,
2578                                                                                   &strDisconnectNotifInfo,
2579                                                                                   pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
2580
2581                        } else {
2582                                PRINT_ER("Connect result callback function is NULL\n");
2583                        }
2584
2585                        memset(pstrWFIDrv->au8AssociatedBSSID, 0, ETH_ALEN);
2586
2587
2588                        /* Deallocation */
2589
2590                        /* if Information Elements were retrieved from the Received deauth/disassoc frame, then they
2591                         *  should be deallocated here */
2592                        /*
2593                         * if(strDisconnectNotifInfo.ie != NULL)
2594                         * {
2595                         *      kfree(strDisconnectNotifInfo.ie);
2596                         *      strDisconnectNotifInfo.ie = NULL;
2597                         * }
2598                         */
2599
2600                        pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
2601                        if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
2602                                kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
2603                                pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
2604                        }
2605
2606                        if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
2607                                kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
2608                                pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
2609                        }
2610
2611                        pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2612                        if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2613                                kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
2614                                pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
2615                        }
2616
2617                        /*BugID_5213*/
2618                        /*Freeing flushed join request params on receiving*/
2619                        /*MAC_DISCONNECTED while connected*/
2620                        if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == (u32)drvHandler) {
2621                                kfree(gu8FlushedJoinReq);
2622                                gu8FlushedJoinReq = NULL;
2623                        }
2624                        if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == (u32)drvHandler) {
2625                                kfree(gu8FlushedInfoElemAsoc);
2626                                gu8FlushedInfoElemAsoc = NULL;
2627                        }
2628
2629                        pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
2630                        gbScanWhileConnected = false;
2631
2632                } else if ((u8MacStatus == MAC_DISCONNECTED) &&
2633                           (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL)) {
2634                        PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW while scanning\n");
2635                        PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running Scan >>\n\n");
2636                        /*Abort the running scan*/
2637                        del_timer(&pstrWFIDrv->hScanTimer);
2638                        if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult)
2639                                Handle_ScanDone(pstrWFIDrv, SCAN_EVENT_ABORTED);
2640
2641                }
2642
2643        }
2644
2645        WILC_CATCH(s32Error)
2646        {
2647
2648        }
2649
2650        /* Deallocate pstrRcvdGnrlAsyncInfo->pu8Buffer which was prevoisuly allocated by the sending thread */
2651        if (pstrRcvdGnrlAsyncInfo->pu8Buffer != NULL) {
2652                kfree(pstrRcvdGnrlAsyncInfo->pu8Buffer);
2653                pstrRcvdGnrlAsyncInfo->pu8Buffer = NULL;
2654        }
2655
2656        return s32Error;
2657}
2658
2659/**
2660 *  @brief Handle_Key
2661 *  @details       Sending config packet to firmware to set key
2662 *  @param[in]    tstrHostIFkeyAttr* pstrHostIFkeyAttr
2663 *  @return         Error code.
2664 *  @author
2665 *  @date
2666 *  @version    1.0
2667 */
2668static int Handle_Key(tstrWILC_WFIDrv *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr)
2669{
2670        s32 s32Error = WILC_SUCCESS;
2671        tstrWID strWID;
2672        #ifdef WILC_AP_EXTERNAL_MLME
2673        tstrWID strWIDList[5];
2674        #endif
2675        u8 i;
2676        u8 *pu8keybuf;
2677        s8 s8idxarray[1];
2678        s8 ret = 0;
2679        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
2680
2681
2682        switch (pstrHostIFkeyAttr->enuKeyType) {
2683
2684
2685        case WEP:
2686
2687#ifdef WILC_AP_EXTERNAL_MLME
2688                if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
2689
2690                        PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
2691                        PRINT_D(GENERIC_DBG, "ID Hostint is %d\n", (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
2692                        strWIDList[0].u16WIDid = (u16)WID_11I_MODE;
2693                        strWIDList[0].enuWIDtype = WID_CHAR;
2694                        strWIDList[0].s32ValueSize = sizeof(char);
2695                        strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8mode));
2696
2697                        strWIDList[1].u16WIDid     = WID_AUTH_TYPE;
2698                        strWIDList[1].enuWIDtype  = WID_CHAR;
2699                        strWIDList[1].s32ValueSize = sizeof(char);
2700                        strWIDList[1].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.tenuAuth_type));
2701
2702                        strWIDList[2].u16WIDid  = (u16)WID_KEY_ID;
2703                        strWIDList[2].enuWIDtype        = WID_CHAR;
2704
2705                        strWIDList[2].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
2706                        strWIDList[2].s32ValueSize = sizeof(char);
2707
2708
2709                        pu8keybuf = WILC_MALLOC(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen);
2710
2711
2712                        if (pu8keybuf == NULL) {
2713                                PRINT_ER("No buffer to send Key\n");
2714                                return -1;
2715                        }
2716
2717                        memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
2718                                    pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen);
2719
2720
2721                        kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey);
2722
2723                        strWIDList[3].u16WIDid = (u16)WID_WEP_KEY_VALUE;
2724                        strWIDList[3].enuWIDtype = WID_STR;
2725                        strWIDList[3].s32ValueSize = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen;
2726                        strWIDList[3].ps8WidVal = (s8 *)pu8keybuf;
2727
2728
2729                        s32Error = SendConfigPkt(SET_CFG, strWIDList, 4, true, (u32)pstrWFIDrv);
2730                        kfree(pu8keybuf);
2731
2732
2733                }
2734#endif
2735
2736                if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
2737                        PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
2738                        pu8keybuf = WILC_MALLOC(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen + 2);
2739                        if (pu8keybuf == NULL) {
2740                                PRINT_ER("No buffer to send Key\n");
2741                                return -1;
2742                        }
2743                        pu8keybuf[0] = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx;
2744
2745                        memcpy(pu8keybuf + 1, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen, 1);
2746
2747                        memcpy(pu8keybuf + 2, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
2748                                    pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen);
2749
2750                        kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey);
2751
2752                        strWID.u16WIDid = (u16)WID_ADD_WEP_KEY;
2753                        strWID.enuWIDtype       = WID_STR;
2754                        strWID.ps8WidVal        = (s8 *)pu8keybuf;
2755                        strWID.s32ValueSize = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen + 2;
2756
2757                        s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
2758                        kfree(pu8keybuf);
2759                } else if (pstrHostIFkeyAttr->u8KeyAction & REMOVEKEY)    {
2760
2761                        PRINT_D(HOSTINF_DBG, "Removing key\n");
2762                        strWID.u16WIDid = (u16)WID_REMOVE_WEP_KEY;
2763                        strWID.enuWIDtype       = WID_STR;
2764
2765                        s8idxarray[0] = (s8)pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx;
2766                        strWID.ps8WidVal = s8idxarray;
2767                        strWID.s32ValueSize = 1;
2768
2769                        s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
2770                } else {
2771                        strWID.u16WIDid = (u16)WID_KEY_ID;
2772                        strWID.enuWIDtype       = WID_CHAR;
2773                        strWID.ps8WidVal        = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
2774                        strWID.s32ValueSize = sizeof(char);
2775
2776                        PRINT_D(HOSTINF_DBG, "Setting default key index\n");
2777
2778                        s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
2779                }
2780                up(&(pstrWFIDrv->hSemTestKeyBlock));
2781                break;
2782
2783        case WPARxGtk:
2784                        #ifdef WILC_AP_EXTERNAL_MLME
2785                if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
2786                        pu8keybuf = WILC_MALLOC(RX_MIC_KEY_MSG_LEN);
2787                        if (pu8keybuf == NULL) {
2788                                PRINT_ER("No buffer to send RxGTK Key\n");
2789                                ret = -1;
2790                                goto _WPARxGtk_end_case_;
2791                        }
2792
2793                        memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN);
2794
2795
2796                        /*|----------------------------------------------------------------------------|
2797                         * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key   | Rx Michael Key |
2798                         * |------------|---------|-------|------------|---------------|----------------|
2799                         |      6 bytes  | 8 byte  |1 byte |  1 byte    |   16 bytes    |         8 bytes        |*/
2800
2801
2802
2803                        if (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq != NULL)
2804                                memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq, 8);
2805
2806
2807                        memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
2808
2809                        memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
2810
2811                        memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
2812                                    pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2813                        /* pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode =  0X51; */
2814                        strWIDList[0].u16WIDid = (u16)WID_11I_MODE;
2815                        strWIDList[0].enuWIDtype = WID_CHAR;
2816                        strWIDList[0].s32ValueSize = sizeof(char);
2817                        strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode));
2818
2819                        strWIDList[1].u16WIDid  = (u16)WID_ADD_RX_GTK;
2820                        strWIDList[1].enuWIDtype        = WID_STR;
2821                        strWIDList[1].ps8WidVal = (s8 *)pu8keybuf;
2822                        strWIDList[1].s32ValueSize = RX_MIC_KEY_MSG_LEN;
2823
2824                        s32Error = SendConfigPkt(SET_CFG, strWIDList, 2, true, (u32)pstrWFIDrv);
2825
2826                        kfree(pu8keybuf);
2827
2828                        /* ////////////////////////// */
2829                        up(&(pstrWFIDrv->hSemTestKeyBlock));
2830                        /* ///////////////////////// */
2831                }
2832
2833                        #endif
2834                if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
2835                        PRINT_D(HOSTINF_DBG, "Handling group key(Rx) function\n");
2836
2837                        pu8keybuf = WILC_MALLOC(RX_MIC_KEY_MSG_LEN);
2838                        if (pu8keybuf == NULL) {
2839                                PRINT_ER("No buffer to send RxGTK Key\n");
2840                                ret = -1;
2841                                goto _WPARxGtk_end_case_;
2842                        }
2843
2844                        memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN);
2845
2846
2847                        /*|----------------------------------------------------------------------------|
2848                         * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key   | Rx Michael Key |
2849                         * |------------|---------|-------|------------|---------------|----------------|
2850                         |      6 bytes  | 8 byte  |1 byte |  1 byte    |   16 bytes    |         8 bytes        |*/
2851
2852                        if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED)
2853                                memcpy(pu8keybuf, pstrWFIDrv->au8AssociatedBSSID, ETH_ALEN);
2854                        else
2855                                PRINT_ER("Couldn't handle WPARxGtk while enuHostIFstate is not HOST_IF_CONNECTED\n");
2856
2857                        memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq, 8);
2858
2859                        memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
2860
2861                        memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
2862                        memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
2863                                    pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2864
2865                        strWID.u16WIDid = (u16)WID_ADD_RX_GTK;
2866                        strWID.enuWIDtype       = WID_STR;
2867                        strWID.ps8WidVal        = (s8 *)pu8keybuf;
2868                        strWID.s32ValueSize = RX_MIC_KEY_MSG_LEN;
2869
2870                        s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
2871
2872                        kfree(pu8keybuf);
2873
2874                        /* ////////////////////////// */
2875                        up(&(pstrWFIDrv->hSemTestKeyBlock));
2876                        /* ///////////////////////// */
2877                }
2878_WPARxGtk_end_case_:
2879                kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key);
2880                kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq);
2881                if (ret == -1)
2882                        return ret;
2883
2884                break;
2885
2886        case WPAPtk:
2887                #ifdef WILC_AP_EXTERNAL_MLME
2888                if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
2889
2890
2891                        pu8keybuf = WILC_MALLOC(PTK_KEY_MSG_LEN + 1);
2892
2893
2894
2895                        if (pu8keybuf == NULL) {
2896                                PRINT_ER("No buffer to send PTK Key\n");
2897                                ret = -1;
2898                                goto _WPAPtk_end_case_;
2899
2900                        }
2901
2902                        /*|-----------------------------------------------------------------------------|
2903                         * |Station address |   keyidx     |Key Length    |Temporal Key  | Rx Michael Key |Tx Michael Key |
2904                         * |----------------|------------  |--------------|----------------|---------------|
2905                         |      6 bytes    |    1 byte    |   1byte      |   16 bytes    |        8 bytes         |        8 bytes        |
2906                         |-----------------------------------------------------------------------------|*/
2907
2908                        memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr, 6);  /*1 bytes Key Length */
2909
2910                        memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
2911                        memcpy(pu8keybuf + 7, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
2912                        /*16 byte TK*/
2913                        memcpy(pu8keybuf + 8, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
2914                                    pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2915
2916
2917                        strWIDList[0].u16WIDid = (u16)WID_11I_MODE;
2918                        strWIDList[0].enuWIDtype = WID_CHAR;
2919                        strWIDList[0].s32ValueSize = sizeof(char);
2920                        strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode));
2921
2922                        strWIDList[1].u16WIDid  = (u16)WID_ADD_PTK;
2923                        strWIDList[1].enuWIDtype        = WID_STR;
2924                        strWIDList[1].ps8WidVal = (s8 *)pu8keybuf;
2925                        strWIDList[1].s32ValueSize = PTK_KEY_MSG_LEN + 1;
2926
2927                        s32Error = SendConfigPkt(SET_CFG, strWIDList, 2, true, (u32)pstrWFIDrv);
2928                        kfree(pu8keybuf);
2929
2930                        /* ////////////////////////// */
2931                        up(&(pstrWFIDrv->hSemTestKeyBlock));
2932                        /* ///////////////////////// */
2933                }
2934                #endif
2935                if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
2936
2937
2938                        pu8keybuf = WILC_MALLOC(PTK_KEY_MSG_LEN);
2939
2940
2941
2942                        if (pu8keybuf == NULL) {
2943                                PRINT_ER("No buffer to send PTK Key\n");
2944                                ret = -1;
2945                                goto _WPAPtk_end_case_;
2946
2947                        }
2948
2949                        /*|-----------------------------------------------------------------------------|
2950                         * |Station address | Key Length |      Temporal Key | Rx Michael Key |Tx Michael Key |
2951                         * |----------------|------------|--------------|----------------|---------------|
2952                         |      6 bytes          |      1byte     |   16 bytes   |        8 bytes         |        8 bytes        |
2953                         |-----------------------------------------------------------------------------|*/
2954
2955                        memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr, 6);  /*1 bytes Key Length */
2956
2957                        memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
2958                        /*16 byte TK*/
2959                        memcpy(pu8keybuf + 7, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
2960                                    pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2961
2962
2963                        strWID.u16WIDid = (u16)WID_ADD_PTK;
2964                        strWID.enuWIDtype       = WID_STR;
2965                        strWID.ps8WidVal        = (s8 *)pu8keybuf;
2966                        strWID.s32ValueSize = PTK_KEY_MSG_LEN;
2967
2968                        s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
2969                        kfree(pu8keybuf);
2970
2971                        /* ////////////////////////// */
2972                        up(&(pstrWFIDrv->hSemTestKeyBlock));
2973                        /* ///////////////////////// */
2974                }
2975
2976_WPAPtk_end_case_:
2977                kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key);
2978                if (ret == -1)
2979                        return ret;
2980
2981                break;
2982
2983
2984        case PMKSA:
2985
2986                PRINT_D(HOSTINF_DBG, "Handling PMKSA key\n");
2987
2988                pu8keybuf = WILC_MALLOC((pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid * PMKSA_KEY_LEN) + 1);
2989                if (pu8keybuf == NULL) {
2990                        PRINT_ER("No buffer to send PMKSA Key\n");
2991                        return -1;
2992                }
2993
2994                pu8keybuf[0] = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid;
2995
2996                for (i = 0; i < pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid; i++) {
2997
2998                        memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + 1), pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].bssid, ETH_ALEN);
2999                        memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1), pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].pmkid, PMKID_LEN);
3000                }
3001
3002                strWID.u16WIDid = (u16)WID_PMKID_INFO;
3003                strWID.enuWIDtype = WID_STR;
3004                strWID.ps8WidVal = (s8 *)pu8keybuf;
3005                strWID.s32ValueSize = (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid * PMKSA_KEY_LEN) + 1;
3006
3007                s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3008
3009                kfree(pu8keybuf);
3010                break;
3011        }
3012
3013        if (s32Error)
3014                PRINT_ER("Failed to send key config packet\n");
3015
3016
3017        return s32Error;
3018}
3019
3020
3021/**
3022 *  @brief Handle_Disconnect
3023 *  @details       Sending config packet to firmware to disconnect
3024 *  @param[in]    NONE
3025 *  @return         NONE
3026 *  @author
3027 *  @date
3028 *  @version    1.0
3029 */
3030static void Handle_Disconnect(tstrWILC_WFIDrv *drvHandler)
3031{
3032        tstrWID strWID;
3033
3034        s32 s32Error = WILC_SUCCESS;
3035        u16 u16DummyReasonCode = 0;
3036        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3037
3038
3039        strWID.u16WIDid = (u16)WID_DISCONNECT;
3040        strWID.enuWIDtype = WID_CHAR;
3041        strWID.ps8WidVal = (s8 *)&u16DummyReasonCode;
3042        strWID.s32ValueSize = sizeof(char);
3043
3044
3045
3046        PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
3047
3048        #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3049
3050        g_obtainingIP = false;
3051        host_int_set_power_mgmt(pstrWFIDrv, 0, 0);
3052        #endif
3053
3054        memset(u8ConnectedSSID, 0, ETH_ALEN);
3055
3056        s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv);
3057
3058        if (s32Error) {
3059                PRINT_ER("Failed to send dissconect config packet\n");
3060                WILC_ERRORREPORT(s32Error, WILC_FAIL);
3061        } else {
3062                tstrDisconnectNotifInfo strDisconnectNotifInfo;
3063
3064                memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
3065
3066                strDisconnectNotifInfo.u16reason = 0;
3067                strDisconnectNotifInfo.ie = NULL;
3068                strDisconnectNotifInfo.ie_len = 0;
3069
3070                if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
3071                        del_timer(&pstrWFIDrv->hScanTimer);
3072                        pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
3073                                                                        pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
3074
3075                        pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
3076                }
3077
3078                if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
3079
3080                        /*BugID_5193*/
3081                        /*Stop connect timer, if connection in progress*/
3082                        if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
3083                                PRINT_D(HOSTINF_DBG, "Upper layer requested termination of connection\n");
3084                                del_timer(&pstrWFIDrv->hConnectTimer);
3085                        }
3086
3087                        pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF, NULL,
3088                                                                           0, &strDisconnectNotifInfo, pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
3089                } else {
3090                        PRINT_ER("strWILC_UsrConnReq.pfUserConnectResult = NULL\n");
3091                }
3092
3093                gbScanWhileConnected = false;
3094
3095                pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
3096
3097                memset(pstrWFIDrv->au8AssociatedBSSID, 0, ETH_ALEN);
3098
3099
3100                /* Deallocation */
3101                pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
3102                if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
3103                        kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
3104                        pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
3105                }
3106
3107                if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
3108                        kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
3109                        pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
3110                }
3111
3112                pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
3113                if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
3114                        kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
3115                        pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
3116                }
3117
3118
3119                /*BugID_5137*/
3120                if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == (u32)drvHandler) {
3121                        kfree(gu8FlushedJoinReq);
3122                        gu8FlushedJoinReq = NULL;
3123                }
3124                if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == (u32)drvHandler) {
3125                        kfree(gu8FlushedInfoElemAsoc);
3126                        gu8FlushedInfoElemAsoc = NULL;
3127                }
3128
3129        }
3130
3131        WILC_CATCH(s32Error)
3132        {
3133
3134        }
3135
3136        /* ////////////////////////// */
3137        up(&(pstrWFIDrv->hSemTestDisconnectBlock));
3138        /* ///////////////////////// */
3139
3140}
3141
3142
3143void resolve_disconnect_aberration(tstrWILC_WFIDrv *drvHandler)
3144{
3145        tstrWILC_WFIDrv *pstrWFIDrv;
3146
3147        pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3148        if (pstrWFIDrv  == NULL)
3149                return;
3150        if ((pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) || (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTING)) {
3151                PRINT_D(HOSTINF_DBG, "\n\n<< correcting Supplicant state machine >>\n\n");
3152                host_int_disconnect(pstrWFIDrv, 1);
3153        }
3154}
3155static s32 Switch_Log_Terminal(tstrWILC_WFIDrv *drvHandler)
3156{
3157
3158
3159        s32 s32Error = WILC_SUCCESS;
3160        tstrWID strWID;
3161        static char dummy = 9;
3162        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3163
3164        strWID.u16WIDid = (u16)WID_LOGTerminal_Switch;
3165        strWID.enuWIDtype = WID_CHAR;
3166        strWID.ps8WidVal = &dummy;
3167        strWID.s32ValueSize = sizeof(char);
3168
3169        s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3170
3171
3172        if (s32Error) {
3173                PRINT_D(HOSTINF_DBG, "Failed to switch log terminal\n");
3174                WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
3175        } else {
3176                PRINT_INFO(HOSTINF_DBG, "MAC address set ::\n");
3177
3178
3179        }
3180
3181        WILC_CATCH(s32Error)
3182        {
3183
3184        }
3185
3186        return s32Error;
3187}
3188
3189/**
3190 *  @brief Handle_GetChnl
3191 *  @details       Sending config packet to get channel
3192 *  @param[in]    NONE
3193 *  @return         NONE
3194 *
3195 *  @author
3196 *  @date
3197 *  @version    1.0
3198 */
3199static s32 Handle_GetChnl(tstrWILC_WFIDrv *drvHandler)
3200{
3201
3202        s32 s32Error = WILC_SUCCESS;
3203        tstrWID strWID;
3204        /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
3205        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3206
3207        strWID.u16WIDid = (u16)WID_CURRENT_CHANNEL;
3208        strWID.enuWIDtype = WID_CHAR;
3209        strWID.ps8WidVal = (s8 *)&gu8Chnl;
3210        strWID.s32ValueSize = sizeof(char);
3211
3212        PRINT_D(HOSTINF_DBG, "Getting channel value\n");
3213
3214        s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3215        /*get the value by searching the local copy*/
3216        if (s32Error) {
3217                PRINT_ER("Failed to get channel number\n");
3218                WILC_ERRORREPORT(s32Error, WILC_FAIL);
3219        }
3220
3221
3222        WILC_CATCH(s32Error)
3223        {
3224
3225        }
3226        up(&(pstrWFIDrv->hSemGetCHNL));
3227
3228        return s32Error;
3229
3230
3231
3232}
3233
3234
3235/**
3236 *  @brief Handle_GetRssi
3237 *  @details       Sending config packet to get RSSI
3238 *  @param[in]    NONE
3239 *  @return         NONE
3240 *  @author
3241 *  @date
3242 *  @version    1.0
3243 */
3244static void Handle_GetRssi(tstrWILC_WFIDrv *drvHandler)
3245{
3246        s32 s32Error = WILC_SUCCESS;
3247        tstrWID strWID;
3248        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3249
3250        strWID.u16WIDid = (u16)WID_RSSI;
3251        strWID.enuWIDtype = WID_CHAR;
3252        strWID.ps8WidVal = &gs8Rssi;
3253        strWID.s32ValueSize = sizeof(char);
3254
3255        /*Sending Cfg*/
3256        PRINT_D(HOSTINF_DBG, "Getting RSSI value\n");
3257
3258        s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3259        if (s32Error) {
3260                PRINT_ER("Failed to get RSSI value\n");
3261                WILC_ERRORREPORT(s32Error, WILC_FAIL);
3262        }
3263
3264        WILC_CATCH(s32Error)
3265        {
3266
3267        }
3268        up(&(pstrWFIDrv->hSemGetRSSI));
3269
3270
3271}
3272
3273
3274static void Handle_GetLinkspeed(tstrWILC_WFIDrv *drvHandler)
3275{
3276        s32 s32Error = WILC_SUCCESS;
3277        tstrWID strWID;
3278        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3279
3280        gs8lnkspd = 0;
3281
3282        strWID.u16WIDid = (u16)WID_LINKSPEED;
3283        strWID.enuWIDtype = WID_CHAR;
3284        strWID.ps8WidVal = &gs8lnkspd;
3285        strWID.s32ValueSize = sizeof(char);
3286        /*Sending Cfg*/
3287        PRINT_D(HOSTINF_DBG, "Getting LINKSPEED value\n");
3288
3289        s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3290        if (s32Error) {
3291                PRINT_ER("Failed to get LINKSPEED value\n");
3292                WILC_ERRORREPORT(s32Error, WILC_FAIL);
3293        }
3294
3295        WILC_CATCH(s32Error)
3296        {
3297
3298        }
3299        up(&(pstrWFIDrv->hSemGetLINKSPEED));
3300
3301
3302}
3303
3304s32 Handle_GetStatistics(tstrWILC_WFIDrv *drvHandler, tstrStatistics *pstrStatistics)
3305{
3306        tstrWID strWIDList[5];
3307        uint32_t u32WidsCount = 0, s32Error = 0;
3308
3309        strWIDList[u32WidsCount].u16WIDid = WID_LINKSPEED;
3310        strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
3311        strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
3312        strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u8LinkSpeed));
3313        u32WidsCount++;
3314
3315        strWIDList[u32WidsCount].u16WIDid = WID_RSSI;
3316        strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
3317        strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
3318        strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->s8RSSI));
3319        u32WidsCount++;
3320
3321        strWIDList[u32WidsCount].u16WIDid = WID_SUCCESS_FRAME_COUNT;
3322        strWIDList[u32WidsCount].enuWIDtype = WID_INT;
3323        strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
3324        strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32TxCount));
3325        u32WidsCount++;
3326
3327        strWIDList[u32WidsCount].u16WIDid = WID_RECEIVED_FRAGMENT_COUNT;
3328        strWIDList[u32WidsCount].enuWIDtype = WID_INT;
3329        strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
3330        strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32RxCount));
3331        u32WidsCount++;
3332
3333        strWIDList[u32WidsCount].u16WIDid = WID_FAILED_COUNT;
3334        strWIDList[u32WidsCount].enuWIDtype = WID_INT;
3335        strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
3336        strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32TxFailureCount));
3337        u32WidsCount++;
3338
3339        s32Error = SendConfigPkt(GET_CFG, strWIDList, u32WidsCount, false, (u32)drvHandler);
3340
3341        if (s32Error) {
3342                PRINT_ER("Failed to send scan paramters config packet\n");
3343                /* WILC_ERRORREPORT(s32Error, s32Error); */
3344        }
3345        up(&hWaitResponse);
3346        return 0;
3347
3348}
3349
3350
3351#ifdef WILC_AP_EXTERNAL_MLME
3352
3353
3354/**
3355 *  @brief Handle_Get_InActiveTime
3356 *  @details       Sending config packet to set mac adddress for station and
3357 *                 get inactive time
3358 *  @param[in]    NONE
3359 *  @return         NONE
3360 *
3361 *  @author
3362 *  @date
3363 *  @version    1.0
3364 */
3365static s32 Handle_Get_InActiveTime(tstrWILC_WFIDrv *drvHandler, tstrHostIfStaInactiveT *strHostIfStaInactiveT)
3366{
3367
3368        s32 s32Error = WILC_SUCCESS;
3369        u8 *stamac;
3370        tstrWID strWID;
3371        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3372
3373
3374        strWID.u16WIDid = (u16)WID_SET_STA_MAC_INACTIVE_TIME;
3375        strWID.enuWIDtype = WID_STR;
3376        strWID.s32ValueSize = ETH_ALEN;
3377        strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
3378
3379
3380        stamac = strWID.ps8WidVal;
3381        memcpy(stamac, strHostIfStaInactiveT->mac, ETH_ALEN);
3382
3383
3384        PRINT_D(CFG80211_DBG, "SETING STA inactive time\n");
3385
3386
3387        s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3388        /*get the value by searching the local copy*/
3389        if (s32Error) {
3390                PRINT_ER("Failed to SET incative time\n");
3391                WILC_ERRORREPORT(s32Error, WILC_FAIL);
3392        }
3393
3394
3395        strWID.u16WIDid = (u16)WID_GET_INACTIVE_TIME;
3396        strWID.enuWIDtype = WID_INT;
3397        strWID.ps8WidVal = (s8 *)&gu32InactiveTime;
3398        strWID.s32ValueSize = sizeof(u32);
3399
3400
3401        s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3402        /*get the value by searching the local copy*/
3403        if (s32Error) {
3404                PRINT_ER("Failed to get incative time\n");
3405                WILC_ERRORREPORT(s32Error, WILC_FAIL);
3406        }
3407
3408
3409        PRINT_D(CFG80211_DBG, "Getting inactive time : %d\n", gu32InactiveTime);
3410
3411        up(&(pstrWFIDrv->hSemInactiveTime));
3412        WILC_CATCH(s32Error)
3413        {
3414
3415        }
3416
3417
3418        return s32Error;
3419
3420
3421
3422}
3423
3424
3425/**
3426 *  @brief Handle_AddBeacon
3427 *  @details       Sending config packet to add beacon
3428 *  @param[in]    tstrHostIFSetBeacon* pstrSetBeaconParam
3429 *  @return         NONE
3430 *  @author
3431 *  @date
3432 *  @version    1.0
3433 */
3434static void Handle_AddBeacon(tstrWILC_WFIDrv *drvHandler, tstrHostIFSetBeacon *pstrSetBeaconParam)
3435{
3436        s32 s32Error = WILC_SUCCESS;
3437        tstrWID strWID;
3438        u8 *pu8CurrByte;
3439        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3440
3441        PRINT_D(HOSTINF_DBG, "Adding BEACON\n");
3442
3443        strWID.u16WIDid = (u16)WID_ADD_BEACON;
3444        strWID.enuWIDtype = WID_BIN;
3445        strWID.s32ValueSize = pstrSetBeaconParam->u32HeadLen + pstrSetBeaconParam->u32TailLen + 16;
3446        strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
3447        if (strWID.ps8WidVal == NULL)
3448                WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
3449
3450        pu8CurrByte = strWID.ps8WidVal;
3451        *pu8CurrByte++ = (pstrSetBeaconParam->u32Interval & 0xFF);
3452        *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 8) & 0xFF);
3453        *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 16) & 0xFF);
3454        *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 24) & 0xFF);
3455
3456        *pu8CurrByte++ = (pstrSetBeaconParam->u32DTIMPeriod & 0xFF);
3457        *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 8) & 0xFF);
3458        *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 16) & 0xFF);
3459        *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 24) & 0xFF);
3460
3461        *pu8CurrByte++ = (pstrSetBeaconParam->u32HeadLen & 0xFF);
3462        *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 8) & 0xFF);
3463        *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 16) & 0xFF);
3464        *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 24) & 0xFF);
3465
3466        memcpy(pu8CurrByte, pstrSetBeaconParam->pu8Head, pstrSetBeaconParam->u32HeadLen);
3467        pu8CurrByte += pstrSetBeaconParam->u32HeadLen;
3468
3469        *pu8CurrByte++ = (pstrSetBeaconParam->u32TailLen & 0xFF);
3470        *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 8) & 0xFF);
3471        *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 16) & 0xFF);
3472        *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 24) & 0xFF);
3473
3474        /* Bug 4599 : if tail length = 0 skip copying */
3475        if (pstrSetBeaconParam->pu8Tail > 0)
3476                memcpy(pu8CurrByte, pstrSetBeaconParam->pu8Tail, pstrSetBeaconParam->u32TailLen);
3477        pu8CurrByte += pstrSetBeaconParam->u32TailLen;
3478
3479
3480
3481        /*Sending Cfg*/
3482        s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv);
3483        if (s32Error) {
3484                PRINT_ER("Failed to send add beacon config packet\n");
3485                WILC_ERRORREPORT(s32Error, WILC_FAIL);
3486        }
3487
3488        WILC_CATCH(s32Error)
3489        {
3490        }
3491        kfree(strWID.ps8WidVal);
3492        kfree(pstrSetBeaconParam->pu8Head);
3493        kfree(pstrSetBeaconParam->pu8Tail);
3494}
3495
3496
3497/**
3498 *  @brief Handle_AddBeacon
3499 *  @details       Sending config packet to delete beacon
3500 *  @param[in]   tstrHostIFDelBeacon* pstrDelBeacon
3501 *  @return         NONE
3502 *  @author
3503 *  @date
3504 *  @version    1.0
3505 */
3506static void Handle_DelBeacon(tstrWILC_WFIDrv *drvHandler, tstrHostIFDelBeacon *pstrDelBeacon)
3507{
3508        s32 s32Error = WILC_SUCCESS;
3509        tstrWID strWID;
3510        u8 *pu8CurrByte;
3511        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3512
3513        strWID.u16WIDid = (u16)WID_DEL_BEACON;
3514        strWID.enuWIDtype = WID_CHAR;
3515        strWID.s32ValueSize = sizeof(char);
3516        strWID.ps8WidVal = &gu8DelBcn;
3517
3518        if (strWID.ps8WidVal == NULL)
3519                WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
3520
3521        pu8CurrByte = strWID.ps8WidVal;
3522
3523        PRINT_D(HOSTINF_DBG, "Deleting BEACON\n");
3524        /* TODO: build del beacon message*/
3525
3526        /*Sending Cfg*/
3527        s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv);
3528        if (s32Error) {
3529
3530                PRINT_ER("Failed to send delete beacon config packet\n");
3531                WILC_ERRORREPORT(s32Error, WILC_FAIL);
3532        }
3533
3534        WILC_CATCH(s32Error)
3535        {
3536        }
3537}
3538
3539
3540/**
3541 *  @brief WILC_HostIf_PackStaParam
3542 *  @details       Handling packing of the station params in a buffer
3543 *  @param[in]   u8* pu8Buffer, tstrWILC_AddStaParam* pstrStationParam
3544 *  @return         NONE
3545 *  @author
3546 *  @date
3547 *  @version    1.0
3548 */
3549static u32 WILC_HostIf_PackStaParam(u8 *pu8Buffer, tstrWILC_AddStaParam *pstrStationParam)
3550{
3551        u8 *pu8CurrByte;
3552
3553        pu8CurrByte = pu8Buffer;
3554
3555        PRINT_D(HOSTINF_DBG, "Packing STA params\n");
3556        memcpy(pu8CurrByte, pstrStationParam->au8BSSID, ETH_ALEN);
3557        pu8CurrByte +=  ETH_ALEN;
3558
3559        *pu8CurrByte++ = pstrStationParam->u16AssocID & 0xFF;
3560        *pu8CurrByte++ = (pstrStationParam->u16AssocID >> 8) & 0xFF;
3561
3562        *pu8CurrByte++ = pstrStationParam->u8NumRates;
3563        if (pstrStationParam->u8NumRates > 0)
3564                memcpy(pu8CurrByte, pstrStationParam->pu8Rates, pstrStationParam->u8NumRates);
3565        pu8CurrByte += pstrStationParam->u8NumRates;
3566
3567        *pu8CurrByte++ = pstrStationParam->bIsHTSupported;
3568        *pu8CurrByte++ = pstrStationParam->u16HTCapInfo & 0xFF;
3569        *pu8CurrByte++ = (pstrStationParam->u16HTCapInfo >> 8) & 0xFF;
3570
3571        *pu8CurrByte++ = pstrStationParam->u8AmpduParams;
3572        memcpy(pu8CurrByte, pstrStationParam->au8SuppMCsSet, WILC_SUPP_MCS_SET_SIZE);
3573        pu8CurrByte += WILC_SUPP_MCS_SET_SIZE;
3574
3575        *pu8CurrByte++ = pstrStationParam->u16HTExtParams & 0xFF;
3576        *pu8CurrByte++ = (pstrStationParam->u16HTExtParams >> 8) & 0xFF;
3577
3578        *pu8CurrByte++ = pstrStationParam->u32TxBeamformingCap & 0xFF;
3579        *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 8) & 0xFF;
3580        *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 16) & 0xFF;
3581        *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 24) & 0xFF;
3582
3583        *pu8CurrByte++ = pstrStationParam->u8ASELCap;
3584
3585        *pu8CurrByte++ = pstrStationParam->u16FlagsMask & 0xFF;
3586        *pu8CurrByte++ = (pstrStationParam->u16FlagsMask >> 8) & 0xFF;
3587
3588        *pu8CurrByte++ = pstrStationParam->u16FlagsSet & 0xFF;
3589        *pu8CurrByte++ = (pstrStationParam->u16FlagsSet >> 8) & 0xFF;
3590
3591        return pu8CurrByte - pu8Buffer;
3592}
3593
3594/**
3595 *  @brief Handle_AddStation
3596 *  @details       Sending config packet to add station
3597 *  @param[in]   tstrWILC_AddStaParam* pstrStationParam
3598 *  @return         NONE
3599 *  @author
3600 *  @date
3601 *  @version    1.0
3602 */
3603static void Handle_AddStation(tstrWILC_WFIDrv *drvHandler, tstrWILC_AddStaParam *pstrStationParam)
3604{
3605        s32 s32Error = WILC_SUCCESS;
3606        tstrWID strWID;
3607        u8 *pu8CurrByte;
3608        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3609
3610        PRINT_D(HOSTINF_DBG, "Handling add station\n");
3611        strWID.u16WIDid = (u16)WID_ADD_STA;
3612        strWID.enuWIDtype = WID_BIN;
3613        strWID.s32ValueSize = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
3614
3615        strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
3616        if (strWID.ps8WidVal == NULL)
3617                WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
3618
3619        pu8CurrByte = strWID.ps8WidVal;
3620        pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
3621
3622        /*Sending Cfg*/
3623        s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv);
3624        if (s32Error != WILC_SUCCESS) {
3625
3626                PRINT_ER("Failed to send add station config packet\n");
3627                WILC_ERRORREPORT(s32Error, WILC_FAIL);
3628        }
3629
3630        WILC_CATCH(s32Error)
3631        {
3632        }
3633        kfree(pstrStationParam->pu8Rates);
3634        kfree(strWID.ps8WidVal);
3635}
3636
3637/**
3638 *  @brief Handle_DelAllSta
3639 *  @details        Sending config packet to delete station
3640 *  @param[in]   tstrHostIFDelSta* pstrDelStaParam
3641 *  @return         NONE
3642 *  @author
3643 *  @date
3644 *  @version    1.0
3645 */
3646static void Handle_DelAllSta(tstrWILC_WFIDrv *drvHandler, tstrHostIFDelAllSta *pstrDelAllStaParam)
3647{
3648        s32 s32Error = WILC_SUCCESS;
3649
3650        tstrWID strWID;
3651        u8 *pu8CurrByte;
3652        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3653        u8 i;
3654        u8 au8Zero_Buff[6] = {0};
3655
3656        strWID.u16WIDid = (u16)WID_DEL_ALL_STA;
3657        strWID.enuWIDtype = WID_STR;
3658        strWID.s32ValueSize = (pstrDelAllStaParam->u8Num_AssocSta * ETH_ALEN) + 1;
3659
3660        PRINT_D(HOSTINF_DBG, "Handling delete station\n");
3661
3662        strWID.ps8WidVal = WILC_MALLOC((pstrDelAllStaParam->u8Num_AssocSta * ETH_ALEN) + 1);
3663        if (strWID.ps8WidVal == NULL)
3664                WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
3665
3666        pu8CurrByte = strWID.ps8WidVal;
3667
3668        *(pu8CurrByte++) = pstrDelAllStaParam->u8Num_AssocSta;
3669
3670        for (i = 0; i < MAX_NUM_STA; i++) {
3671                if (memcmp(pstrDelAllStaParam->au8Sta_DelAllSta[i], au8Zero_Buff, ETH_ALEN))
3672                        memcpy(pu8CurrByte, pstrDelAllStaParam->au8Sta_DelAllSta[i], ETH_ALEN);
3673                else
3674                        continue;
3675
3676                pu8CurrByte += ETH_ALEN;
3677        }
3678
3679        /*Sending Cfg*/
3680        s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3681        if (s32Error) {
3682
3683                PRINT_ER("Failed to send add station config packet\n");
3684                WILC_ERRORREPORT(s32Error, WILC_FAIL);
3685        }
3686
3687        WILC_CATCH(s32Error)
3688        {
3689        }
3690        kfree(strWID.ps8WidVal);
3691
3692        up(&hWaitResponse);
3693}
3694
3695
3696/**
3697 *  @brief Handle_DelStation
3698 *  @details        Sending config packet to delete station
3699 *  @param[in]   tstrHostIFDelSta* pstrDelStaParam
3700 *  @return         NONE
3701 *  @author
3702 *  @date
3703 *  @version    1.0
3704 */
3705static void Handle_DelStation(tstrWILC_WFIDrv *drvHandler, tstrHostIFDelSta *pstrDelStaParam)
3706{
3707        s32 s32Error = WILC_SUCCESS;
3708        tstrWID strWID;
3709        u8 *pu8CurrByte;
3710        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3711
3712        strWID.u16WIDid = (u16)WID_REMOVE_STA;
3713        strWID.enuWIDtype = WID_BIN;
3714        strWID.s32ValueSize = ETH_ALEN;
3715
3716        PRINT_D(HOSTINF_DBG, "Handling delete station\n");
3717
3718        strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
3719        if (strWID.ps8WidVal == NULL)
3720                WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
3721
3722        pu8CurrByte = strWID.ps8WidVal;
3723
3724        memcpy(pu8CurrByte, pstrDelStaParam->au8MacAddr, ETH_ALEN);
3725
3726        /*Sending Cfg*/
3727        s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv);
3728        if (s32Error) {
3729
3730                PRINT_ER("Failed to send add station config packet\n");
3731                WILC_ERRORREPORT(s32Error, WILC_FAIL);
3732        }
3733
3734        WILC_CATCH(s32Error)
3735        {
3736        }
3737        kfree(strWID.ps8WidVal);
3738}
3739
3740
3741/**
3742 *  @brief Handle_EditStation
3743 *  @details        Sending config packet to edit station
3744 *  @param[in]   tstrWILC_AddStaParam* pstrStationParam
3745 *  @return         NONE
3746 *  @author
3747 *  @date
3748 *  @version    1.0
3749 */
3750static void Handle_EditStation(tstrWILC_WFIDrv *drvHandler, tstrWILC_AddStaParam *pstrStationParam)
3751{
3752        s32 s32Error = WILC_SUCCESS;
3753        tstrWID strWID;
3754        u8 *pu8CurrByte;
3755        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3756
3757        strWID.u16WIDid = (u16)WID_EDIT_STA;
3758        strWID.enuWIDtype = WID_BIN;
3759        strWID.s32ValueSize = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
3760
3761        PRINT_D(HOSTINF_DBG, "Handling edit station\n");
3762        strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
3763        if (strWID.ps8WidVal == NULL)
3764                WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
3765
3766        pu8CurrByte = strWID.ps8WidVal;
3767        pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
3768
3769        /*Sending Cfg*/
3770        s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv);
3771        if (s32Error) {
3772
3773                PRINT_ER("Failed to send edit station config packet\n");
3774                WILC_ERRORREPORT(s32Error, WILC_FAIL);
3775        }
3776
3777        WILC_CATCH(s32Error)
3778        {
3779        }
3780        kfree(pstrStationParam->pu8Rates);
3781        kfree(strWID.ps8WidVal);
3782}
3783#endif /*WILC_AP_EXTERNAL_MLME*/
3784
3785#ifdef WILC_P2P
3786/**
3787 *  @brief Handle_RemainOnChan
3788 *  @details        Sending config packet to edit station
3789 *  @param[in]   tstrWILC_AddStaParam* pstrStationParam
3790 *  @return         NONE
3791 *  @author
3792 *  @date
3793 *  @version    1.0
3794 */
3795static int Handle_RemainOnChan(tstrWILC_WFIDrv *drvHandler, tstrHostIfRemainOnChan *pstrHostIfRemainOnChan)
3796{
3797        s32 s32Error = WILC_SUCCESS;
3798        u8 u8remain_on_chan_flag;
3799        tstrWID strWID;
3800        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
3801
3802        /*If it's a pendig remain-on-channel, don't overwrite gWFiDrvHandle values (since incoming msg is garbbage)*/
3803        if (!pstrWFIDrv->u8RemainOnChan_pendingreq) {
3804                pstrWFIDrv->strHostIfRemainOnChan.pVoid = pstrHostIfRemainOnChan->pVoid;
3805                pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired = pstrHostIfRemainOnChan->pRemainOnChanExpired;
3806                pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady = pstrHostIfRemainOnChan->pRemainOnChanReady;
3807                pstrWFIDrv->strHostIfRemainOnChan.u16Channel = pstrHostIfRemainOnChan->u16Channel;
3808                pstrWFIDrv->strHostIfRemainOnChan.u32ListenSessionID = pstrHostIfRemainOnChan->u32ListenSessionID;
3809        } else {
3810                /*Set the channel to use it as a wid val*/
3811                pstrHostIfRemainOnChan->u16Channel = pstrWFIDrv->strHostIfRemainOnChan.u16Channel;
3812        }
3813
3814        if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
3815                PRINT_INFO(GENERIC_DBG, "Required to remain on chan while scanning return\n");
3816                pstrWFIDrv->u8RemainOnChan_pendingreq = 1;
3817                WILC_ERRORREPORT(s32Error, WILC_BUSY);
3818        }
3819        if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
3820                PRINT_INFO(GENERIC_DBG, "Required to remain on chan while connecting return\n");
3821                WILC_ERRORREPORT(s32Error, WILC_BUSY);
3822        }
3823
3824        #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3825        if (g_obtainingIP || connecting) {
3826                PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
3827                WILC_ERRORREPORT(s32Error, WILC_BUSY);
3828        }
3829        #endif
3830
3831        PRINT_D(HOSTINF_DBG, "Setting channel :%d\n", pstrHostIfRemainOnChan->u16Channel);
3832
3833        u8remain_on_chan_flag = true;
3834        strWID.u16WIDid = (u16)WID_REMAIN_ON_CHAN;
3835        strWID.enuWIDtype       = WID_STR;
3836        strWID.s32ValueSize = 2;
3837        strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
3838
3839        if (strWID.ps8WidVal == NULL)
3840                WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
3841
3842        strWID.ps8WidVal[0] = u8remain_on_chan_flag;
3843        strWID.ps8WidVal[1] = (s8)pstrHostIfRemainOnChan->u16Channel;
3844
3845        /*Sending Cfg*/
3846        s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3847        if (s32Error != WILC_SUCCESS)
3848                PRINT_ER("Failed to set remain on channel\n");
3849
3850        WILC_CATCH(-1)
3851        {
3852                P2P_LISTEN_STATE = 1;
3853                pstrWFIDrv->hRemainOnChannel.data = (unsigned long)pstrWFIDrv;
3854                mod_timer(&pstrWFIDrv->hRemainOnChannel,
3855                          jiffies +
3856                          msecs_to_jiffies(pstrHostIfRemainOnChan->u32duration));
3857
3858                /*Calling CFG ready_on_channel*/
3859                if (pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady)
3860                        pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady(pstrWFIDrv->strHostIfRemainOnChan.pVoid);
3861
3862                if (pstrWFIDrv->u8RemainOnChan_pendingreq)
3863                        pstrWFIDrv->u8RemainOnChan_pendingreq = 0;
3864        }
3865        return s32Error;
3866}
3867
3868/**
3869 *  @brief Handle_RegisterFrame
3870 *  @details
3871 *  @param[in]
3872 *  @return         NONE
3873 *  @author
3874 *  @date
3875 *  @version    1.0
3876 */
3877static int Handle_RegisterFrame(tstrWILC_WFIDrv *drvHandler, tstrHostIfRegisterFrame *pstrHostIfRegisterFrame)
3878{
3879        s32 s32Error = WILC_SUCCESS;
3880        tstrWID strWID;
3881        u8 *pu8CurrByte;
3882        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3883
3884        PRINT_D(HOSTINF_DBG, "Handling frame register Flag : %d FrameType: %d\n", pstrHostIfRegisterFrame->bReg, pstrHostIfRegisterFrame->u16FrameType);
3885
3886        /*prepare configuration packet*/
3887        strWID.u16WIDid = (u16)WID_REGISTER_FRAME;
3888        strWID.enuWIDtype = WID_STR;
3889        strWID.ps8WidVal = WILC_MALLOC(sizeof(u16) + 2);
3890        if (strWID.ps8WidVal == NULL)
3891                WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
3892
3893        pu8CurrByte = strWID.ps8WidVal;
3894
3895        *pu8CurrByte++ = pstrHostIfRegisterFrame->bReg;
3896        *pu8CurrByte++ = pstrHostIfRegisterFrame->u8Regid;
3897        memcpy(pu8CurrByte, &(pstrHostIfRegisterFrame->u16FrameType), sizeof(u16));
3898
3899
3900        strWID.s32ValueSize = sizeof(u16) + 2;
3901
3902
3903        /*Sending Cfg*/
3904        s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3905        if (s32Error) {
3906                PRINT_ER("Failed to frame register config packet\n");
3907                WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
3908        }
3909
3910
3911        WILC_CATCH(s32Error)
3912        {
3913        }
3914
3915        return s32Error;
3916
3917}
3918
3919/**
3920 *  @brief                      Handle_ListenStateExpired
3921 *  @details            Handle of listen state expiration
3922 *  @param[in]          NONE
3923 *  @return             Error code.
3924 *  @author
3925 *  @date
3926 *  @version            1.0
3927 */
3928#define FALSE_FRMWR_CHANNEL 100
3929static u32 Handle_ListenStateExpired(tstrWILC_WFIDrv *drvHandler, tstrHostIfRemainOnChan *pstrHostIfRemainOnChan)
3930{
3931        u8 u8remain_on_chan_flag;
3932        tstrWID strWID;
3933        s32 s32Error = WILC_SUCCESS;
3934        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
3935
3936        PRINT_D(HOSTINF_DBG, "CANCEL REMAIN ON CHAN\n");
3937
3938        /*BugID_5477*/
3939        /*Make sure we are already in listen state*/
3940        /*This is to handle duplicate expiry messages (listen timer fired and supplicant called cancel_remain_on_channel())*/
3941        if (P2P_LISTEN_STATE) {
3942                u8remain_on_chan_flag = false;
3943                strWID.u16WIDid = (u16)WID_REMAIN_ON_CHAN;
3944                strWID.enuWIDtype       = WID_STR;
3945                strWID.s32ValueSize = 2;
3946                strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
3947
3948                if (strWID.ps8WidVal == NULL)
3949                        PRINT_ER("Failed to allocate memory\n");
3950
3951                strWID.ps8WidVal[0] = u8remain_on_chan_flag;
3952                strWID.ps8WidVal[1] = FALSE_FRMWR_CHANNEL;
3953
3954                /*Sending Cfg*/
3955                s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3956                if (s32Error != WILC_SUCCESS) {
3957                        PRINT_ER("Failed to set remain on channel\n");
3958                        goto _done_;
3959                }
3960
3961                if (pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired) {
3962                        pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired(pstrWFIDrv->strHostIfRemainOnChan.pVoid
3963                                                                               , pstrHostIfRemainOnChan->u32ListenSessionID);
3964                }
3965                P2P_LISTEN_STATE = 0;
3966        } else {
3967                PRINT_D(GENERIC_DBG, "Not in listen state\n");
3968                s32Error = WILC_FAIL;
3969        }
3970
3971_done_:
3972        return s32Error;
3973}
3974
3975
3976/**
3977 *  @brief                      ListenTimerCB
3978 *  @details            Callback function of remain-on-channel timer
3979 *  @param[in]          NONE
3980 *  @return             Error code.
3981 *  @author
3982 *  @date
3983 *  @version            1.0
3984 */
3985static void ListenTimerCB(unsigned long arg)
3986{
3987        s32 s32Error = WILC_SUCCESS;
3988        tstrHostIFmsg strHostIFmsg;
3989        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)arg;
3990        /*Stopping remain-on-channel timer*/
3991        del_timer(&pstrWFIDrv->hRemainOnChannel);
3992
3993        /* prepare the Timer Callback message */
3994        memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
3995        strHostIFmsg.u16MsgId = HOST_IF_MSG_LISTEN_TIMER_FIRED;
3996        strHostIFmsg.drvHandler = pstrWFIDrv;
3997        strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u32ListenSessionID = pstrWFIDrv->strHostIfRemainOnChan.u32ListenSessionID;
3998
3999        /* send the message */
4000        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
4001        if (s32Error)
4002                WILC_ERRORREPORT(s32Error, s32Error);
4003        WILC_CATCH(s32Error)
4004        {
4005
4006        }
4007}
4008#endif
4009
4010
4011/**
4012 *  @brief Handle_EditStation
4013 *  @details        Sending config packet to edit station
4014 *  @param[in]   tstrWILC_AddStaParam* pstrStationParam
4015 *  @return         NONE
4016 *  @author
4017 *  @date
4018 *  @version    1.0
4019 */
4020static void Handle_PowerManagement(tstrWILC_WFIDrv *drvHandler, tstrHostIfPowerMgmtParam *strPowerMgmtParam)
4021{
4022        s32 s32Error = WILC_SUCCESS;
4023        tstrWID strWID;
4024        s8 s8PowerMode;
4025        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
4026
4027        strWID.u16WIDid = (u16)WID_POWER_MANAGEMENT;
4028
4029        if (strPowerMgmtParam->bIsEnabled == true)
4030                s8PowerMode = MIN_FAST_PS;
4031        else
4032                s8PowerMode = NO_POWERSAVE;
4033        PRINT_D(HOSTINF_DBG, "Handling power mgmt to %d\n", s8PowerMode);
4034        strWID.ps8WidVal = &s8PowerMode;
4035        strWID.s32ValueSize = sizeof(char);
4036
4037        PRINT_D(HOSTINF_DBG, "Handling Power Management\n");
4038
4039        /*Sending Cfg*/
4040        s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
4041        if (s32Error) {
4042                PRINT_ER("Failed to send power management config packet\n");
4043                WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
4044        }
4045
4046        WILC_CATCH(s32Error)
4047        {
4048
4049        }
4050}
4051
4052/**
4053 *  @brief Handle_SetMulticastFilter
4054 *  @details        Set Multicast filter in firmware
4055 *  @param[in]   tstrHostIFSetMulti* strHostIfSetMulti
4056 *  @return         NONE
4057 *  @author             asobhy
4058 *  @date
4059 *  @version    1.0
4060 */
4061static void Handle_SetMulticastFilter(tstrWILC_WFIDrv *drvHandler, tstrHostIFSetMulti *strHostIfSetMulti)
4062{
4063        s32 s32Error = WILC_SUCCESS;
4064        tstrWID strWID;
4065        u8 *pu8CurrByte;
4066
4067        PRINT_D(HOSTINF_DBG, "Setup Multicast Filter\n");
4068
4069        strWID.u16WIDid = (u16)WID_SETUP_MULTICAST_FILTER;
4070        strWID.enuWIDtype = WID_BIN;
4071        strWID.s32ValueSize = sizeof(tstrHostIFSetMulti) + ((strHostIfSetMulti->u32count) * ETH_ALEN);
4072        strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
4073        if (strWID.ps8WidVal == NULL)
4074                WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
4075
4076        pu8CurrByte = strWID.ps8WidVal;
4077        *pu8CurrByte++ = (strHostIfSetMulti->bIsEnabled & 0xFF);
4078        *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 8) & 0xFF);
4079        *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 16) & 0xFF);
4080        *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 24) & 0xFF);
4081
4082        *pu8CurrByte++ = (strHostIfSetMulti->u32count & 0xFF);
4083        *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 8) & 0xFF);
4084        *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 16) & 0xFF);
4085        *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 24) & 0xFF);
4086
4087        if ((strHostIfSetMulti->u32count) > 0)
4088                memcpy(pu8CurrByte, gau8MulticastMacAddrList, ((strHostIfSetMulti->u32count) * ETH_ALEN));
4089
4090        /*Sending Cfg*/
4091        s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)drvHandler);
4092        if (s32Error) {
4093                PRINT_ER("Failed to send setup multicast config packet\n");
4094                WILC_ERRORREPORT(s32Error, WILC_FAIL);
4095        }
4096
4097        WILC_CATCH(s32Error)
4098        {
4099        }
4100        kfree(strWID.ps8WidVal);
4101
4102}
4103
4104
4105/*BugID_5222*/
4106/**
4107 *  @brief                      Handle_AddBASession
4108 *  @details            Add block ack session
4109 *  @param[in]          tstrHostIFSetMulti* strHostIfSetMulti
4110 *  @return             NONE
4111 *  @author             Amr Abdel-Moghny
4112 *  @date                       Feb. 2014
4113 *  @version            9.0
4114 */
4115static s32 Handle_AddBASession(tstrWILC_WFIDrv *drvHandler, tstrHostIfBASessionInfo *strHostIfBASessionInfo)
4116{
4117        s32 s32Error = WILC_SUCCESS;
4118        tstrWID strWID;
4119        int AddbaTimeout = 100;
4120        char *ptr = NULL;
4121        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
4122
4123        PRINT_D(HOSTINF_DBG, "Opening Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\nBufferSize == %d\nSessionTimeOut = %d\n",
4124                strHostIfBASessionInfo->au8Bssid[0],
4125                strHostIfBASessionInfo->au8Bssid[1],
4126                strHostIfBASessionInfo->au8Bssid[2],
4127                strHostIfBASessionInfo->u16BufferSize,
4128                strHostIfBASessionInfo->u16SessionTimeout,
4129                strHostIfBASessionInfo->u8Ted);
4130
4131        strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
4132        strWID.enuWIDtype = WID_STR;
4133        strWID.ps8WidVal = WILC_MALLOC(BLOCK_ACK_REQ_SIZE);
4134        strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE;
4135        ptr = strWID.ps8WidVal;
4136        /* *ptr++ = 0x14; */
4137        *ptr++ = 0x14;
4138        *ptr++ = 0x3;
4139        *ptr++ = 0x0;
4140        memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
4141        ptr += ETH_ALEN;
4142        *ptr++ = strHostIfBASessionInfo->u8Ted;
4143        /* BA Policy*/
4144        *ptr++ = 1;
4145        /* Buffer size*/
4146        *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
4147        *ptr++ = ((strHostIfBASessionInfo->u16BufferSize >> 16) & 0xFF);
4148        /* BA timeout*/
4149        *ptr++ = (strHostIfBASessionInfo->u16SessionTimeout & 0xFF);
4150        *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
4151        /* ADDBA timeout*/
4152        *ptr++ = (AddbaTimeout & 0xFF);
4153        *ptr++ = ((AddbaTimeout >> 16) & 0xFF);
4154        /* Group Buffer Max Frames*/
4155        *ptr++ = 8;
4156        /* Group Buffer Timeout */
4157        *ptr++ = 0;
4158
4159        s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
4160        if (s32Error)
4161                PRINT_D(HOSTINF_DBG, "Couldn't open BA Session\n");
4162
4163
4164        strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
4165        strWID.enuWIDtype = WID_STR;
4166        strWID.s32ValueSize = 15;
4167        ptr = strWID.ps8WidVal;
4168        /* *ptr++ = 0x14; */
4169        *ptr++ = 15;
4170        *ptr++ = 7;
4171        *ptr++ = 0x2;
4172        memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
4173        ptr += ETH_ALEN;
4174        /* TID*/
4175        *ptr++ = strHostIfBASessionInfo->u8Ted;
4176        /* Max Num MSDU */
4177        *ptr++ = 8;
4178        /* BA timeout*/
4179        *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
4180        *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
4181        /*Ack-Policy */
4182        *ptr++ = 3;
4183        s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
4184
4185        if (strWID.ps8WidVal != NULL)
4186                kfree(strWID.ps8WidVal);
4187
4188        return s32Error;
4189
4190}
4191
4192
4193/*BugID_5222*/
4194/**
4195 *  @brief                      Handle_DelBASession
4196 *  @details            Delete block ack session
4197 *  @param[in]          tstrHostIFSetMulti* strHostIfSetMulti
4198 *  @return             NONE
4199 *  @author             Amr Abdel-Moghny
4200 *  @date                       Feb. 2013
4201 *  @version            9.0
4202 */
4203static s32 Handle_DelBASession(tstrWILC_WFIDrv *drvHandler, tstrHostIfBASessionInfo *strHostIfBASessionInfo)
4204{
4205        s32 s32Error = WILC_SUCCESS;
4206        tstrWID strWID;
4207        char *ptr = NULL;
4208        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
4209
4210        PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
4211                strHostIfBASessionInfo->au8Bssid[0],
4212                strHostIfBASessionInfo->au8Bssid[1],
4213                strHostIfBASessionInfo->au8Bssid[2],
4214                strHostIfBASessionInfo->u8Ted);
4215
4216        strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
4217        strWID.enuWIDtype = WID_STR;
4218        strWID.ps8WidVal = WILC_MALLOC(BLOCK_ACK_REQ_SIZE);
4219        strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE;
4220        ptr = strWID.ps8WidVal;
4221        /* *ptr++ = 0x14; */
4222        *ptr++ = 0x14;
4223        *ptr++ = 0x3;
4224        *ptr++ = 0x2;
4225        memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
4226        ptr += ETH_ALEN;
4227        *ptr++ = strHostIfBASessionInfo->u8Ted;
4228        /* BA direction = recipent*/
4229        *ptr++ = 0;
4230        /* Delba Reason */
4231        *ptr++ = 32; /* Unspecific QOS reason */
4232
4233        s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
4234        if (s32Error)
4235                PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n");
4236
4237
4238        strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
4239        strWID.enuWIDtype = WID_STR;
4240        strWID.s32ValueSize = 15;
4241        ptr = strWID.ps8WidVal;
4242        /* *ptr++ = 0x14; */
4243        *ptr++ = 15;
4244        *ptr++ = 7;
4245        *ptr++ = 0x3;
4246        memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
4247        ptr += ETH_ALEN;
4248        /* TID*/
4249        *ptr++ = strHostIfBASessionInfo->u8Ted;
4250
4251        s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
4252
4253        if (strWID.ps8WidVal != NULL)
4254                kfree(strWID.ps8WidVal);
4255
4256        /*BugID_5222*/
4257        up(&hWaitResponse);
4258
4259        return s32Error;
4260
4261}
4262
4263
4264/**
4265 *  @brief                      Handle_DelAllRxBASessions
4266 *  @details            Delete all Rx BA sessions
4267 *  @param[in]          tstrHostIFSetMulti* strHostIfSetMulti
4268 *  @return             NONE
4269 *  @author             Abdelrahman Sobhy
4270 *  @date                       Feb. 2013
4271 *  @version            9.0
4272 */
4273static s32 Handle_DelAllRxBASessions(tstrWILC_WFIDrv *drvHandler, tstrHostIfBASessionInfo *strHostIfBASessionInfo)
4274{
4275        s32 s32Error = WILC_SUCCESS;
4276        tstrWID strWID;
4277        char *ptr = NULL;
4278        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
4279
4280        PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
4281                strHostIfBASessionInfo->au8Bssid[0],
4282                strHostIfBASessionInfo->au8Bssid[1],
4283                strHostIfBASessionInfo->au8Bssid[2],
4284                strHostIfBASessionInfo->u8Ted);
4285
4286        strWID.u16WIDid = (u16)WID_DEL_ALL_RX_BA;
4287        strWID.enuWIDtype = WID_STR;
4288        strWID.ps8WidVal = WILC_MALLOC(BLOCK_ACK_REQ_SIZE);
4289        strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE;
4290        ptr = strWID.ps8WidVal;
4291        *ptr++ = 0x14;
4292        *ptr++ = 0x3;
4293        *ptr++ = 0x2;
4294        memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
4295        ptr += ETH_ALEN;
4296        *ptr++ = strHostIfBASessionInfo->u8Ted;
4297        /* BA direction = recipent*/
4298        *ptr++ = 0;
4299        /* Delba Reason */
4300        *ptr++ = 32; /* Unspecific QOS reason */
4301
4302        s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
4303        if (s32Error)
4304                PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n");
4305
4306
4307        if (strWID.ps8WidVal != NULL)
4308                kfree(strWID.ps8WidVal);
4309
4310        /*BugID_5222*/
4311        up(&hWaitResponse);
4312
4313        return s32Error;
4314
4315}
4316
4317/**
4318 *  @brief hostIFthread
4319 *  @details        Main thread to handle message queue requests
4320 *  @param[in]   void* pvArg
4321 *  @return         NONE
4322 *  @author
4323 *  @date
4324 *  @version    1.0
4325 */
4326static int hostIFthread(void *pvArg)
4327{
4328        u32 u32Ret;
4329        tstrHostIFmsg strHostIFmsg;
4330        tstrWILC_WFIDrv *pstrWFIDrv;
4331
4332        memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
4333
4334        while (1) {
4335                WILC_MsgQueueRecv(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), &u32Ret);
4336                pstrWFIDrv = (tstrWILC_WFIDrv *)strHostIFmsg.drvHandler;
4337                if (strHostIFmsg.u16MsgId == HOST_IF_MSG_EXIT) {
4338                        PRINT_D(GENERIC_DBG, "THREAD: Exiting HostIfThread\n");
4339                        break;
4340                }
4341
4342
4343                /*Re-Queue HIF message*/
4344                if ((!g_wilc_initialized)) {
4345                        PRINT_D(GENERIC_DBG, "--WAIT--");
4346                        usleep_range(200 * 1000, 200 * 1000);
4347                        WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
4348                        continue;
4349                }
4350
4351                if (strHostIFmsg.u16MsgId == HOST_IF_MSG_CONNECT && pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
4352                        PRINT_D(HOSTINF_DBG, "Requeue connect request till scan done received\n");
4353                        WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
4354                        usleep_range(2 * 1000, 2 * 1000);
4355                        continue;
4356                }
4357
4358                switch (strHostIFmsg.u16MsgId) {
4359                case HOST_IF_MSG_Q_IDLE:
4360                        Handle_wait_msg_q_empty();
4361                        break;
4362
4363                case HOST_IF_MSG_SCAN:
4364                        Handle_Scan(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr);
4365                        break;
4366
4367                case HOST_IF_MSG_CONNECT:
4368                        Handle_Connect(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr);
4369                        break;
4370
4371                /*BugID_5137*/
4372                case HOST_IF_MSG_FLUSH_CONNECT:
4373                        Handle_FlushConnect(strHostIFmsg.drvHandler);
4374                        break;
4375
4376                case HOST_IF_MSG_RCVD_NTWRK_INFO:
4377                        Handle_RcvdNtwrkInfo(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strRcvdNetworkInfo);
4378                        break;
4379
4380                case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO:
4381                        Handle_RcvdGnrlAsyncInfo(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strRcvdGnrlAsyncInfo);
4382                        break;
4383
4384                case HOST_IF_MSG_KEY:
4385                        Handle_Key(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr);
4386                        break;
4387
4388                case HOST_IF_MSG_CFG_PARAMS:
4389
4390                        Handle_CfgParam(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFCfgParamAttr);
4391                        break;
4392
4393                case HOST_IF_MSG_SET_CHANNEL:
4394                        Handle_SetChannel(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFSetChan);
4395                        break;
4396
4397                case HOST_IF_MSG_DISCONNECT:
4398                        Handle_Disconnect(strHostIFmsg.drvHandler);
4399                        break;
4400
4401                case HOST_IF_MSG_RCVD_SCAN_COMPLETE:
4402                        del_timer(&pstrWFIDrv->hScanTimer);
4403                        PRINT_D(HOSTINF_DBG, "scan completed successfully\n");
4404
4405                        /*BugID_5213*/
4406                        /*Allow chip sleep, only if both interfaces are not connected*/
4407                        if (!linux_wlan_get_num_conn_ifcs())
4408                                chip_sleep_manually(INFINITE_SLEEP_TIME);
4409
4410                        Handle_ScanDone(strHostIFmsg.drvHandler, SCAN_EVENT_DONE);
4411
4412                                #ifdef WILC_P2P
4413                        if (pstrWFIDrv->u8RemainOnChan_pendingreq)
4414                                Handle_RemainOnChan(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan);
4415                                #endif
4416
4417                        break;
4418
4419                case HOST_IF_MSG_GET_RSSI:
4420                        Handle_GetRssi(strHostIFmsg.drvHandler);
4421                        break;
4422
4423                case HOST_IF_MSG_GET_LINKSPEED:
4424                        Handle_GetLinkspeed(strHostIFmsg.drvHandler);
4425                        break;
4426
4427                case HOST_IF_MSG_GET_STATISTICS:
4428                        Handle_GetStatistics(strHostIFmsg.drvHandler, (tstrStatistics *)strHostIFmsg.uniHostIFmsgBody.pUserData);
4429                        break;
4430
4431                case HOST_IF_MSG_GET_CHNL:
4432                        Handle_GetChnl(strHostIFmsg.drvHandler);
4433                        break;
4434
4435#ifdef WILC_AP_EXTERNAL_MLME
4436                case HOST_IF_MSG_ADD_BEACON:
4437                        Handle_AddBeacon(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFSetBeacon);
4438                        break;
4439
4440                case HOST_IF_MSG_DEL_BEACON:
4441                        Handle_DelBeacon(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFDelBeacon);
4442                        break;
4443
4444                case HOST_IF_MSG_ADD_STATION:
4445                        Handle_AddStation(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strAddStaParam);
4446                        break;
4447
4448                case HOST_IF_MSG_DEL_STATION:
4449                        Handle_DelStation(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strDelStaParam);
4450                        break;
4451
4452                case HOST_IF_MSG_EDIT_STATION:
4453                        Handle_EditStation(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strEditStaParam);
4454                        break;
4455
4456                case HOST_IF_MSG_GET_INACTIVETIME:
4457                        Handle_Get_InActiveTime(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfStaInactiveT);
4458                        break;
4459
4460#endif /*WILC_AP_EXTERNAL_MLME*/
4461                case HOST_IF_MSG_SCAN_TIMER_FIRED:
4462                        PRINT_D(HOSTINF_DBG, "Scan Timeout\n");
4463
4464                        Handle_ScanDone(strHostIFmsg.drvHandler, SCAN_EVENT_ABORTED);
4465                        break;
4466
4467                case HOST_IF_MSG_CONNECT_TIMER_FIRED:
4468                        PRINT_D(HOSTINF_DBG, "Connect Timeout\n");
4469                        Handle_ConnectTimeout(strHostIFmsg.drvHandler);
4470                        break;
4471
4472                case HOST_IF_MSG_POWER_MGMT:
4473                        Handle_PowerManagement(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strPowerMgmtparam);
4474                        break;
4475
4476                case HOST_IF_MSG_SET_WFIDRV_HANDLER:
4477                        Handle_SetWfiDrvHandler(&strHostIFmsg.uniHostIFmsgBody.strHostIfSetDrvHandler);
4478                        break;
4479
4480                case HOST_IF_MSG_SET_OPERATION_MODE:
4481                        Handle_SetOperationMode(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfSetOperationMode);
4482                        break;
4483
4484                case HOST_IF_MSG_SET_IPADDRESS:
4485                        PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
4486                        Handle_set_IPAddress(strHostIFmsg.drvHandler, strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.au8IPAddr, strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.idx);
4487                        break;
4488
4489                case HOST_IF_MSG_GET_IPADDRESS:
4490                        PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
4491                        Handle_get_IPAddress(strHostIFmsg.drvHandler, strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.au8IPAddr, strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.idx);
4492                        break;
4493
4494                /*BugID_5077*/
4495                case HOST_IF_MSG_SET_MAC_ADDRESS:
4496                        Handle_SetMacAddress(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfSetMacAddress);
4497                        break;
4498
4499                /*BugID_5213*/
4500                case HOST_IF_MSG_GET_MAC_ADDRESS:
4501                        Handle_GetMacAddress(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfGetMacAddress);
4502                        break;
4503
4504#ifdef WILC_P2P
4505                case HOST_IF_MSG_REMAIN_ON_CHAN:
4506                        PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REMAIN_ON_CHAN\n");
4507                        Handle_RemainOnChan(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan);
4508                        break;
4509
4510                case HOST_IF_MSG_REGISTER_FRAME:
4511                        PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REGISTER_FRAME\n");
4512                        Handle_RegisterFrame(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame);
4513                        break;
4514
4515                case HOST_IF_MSG_LISTEN_TIMER_FIRED:
4516                        Handle_ListenStateExpired(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan);
4517                        break;
4518
4519                        #endif
4520                case HOST_IF_MSG_SET_MULTICAST_FILTER:
4521                        PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_MULTICAST_FILTER\n");
4522                        Handle_SetMulticastFilter(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfSetMulti);
4523                        break;
4524
4525                /*BugID_5222*/
4526                case HOST_IF_MSG_ADD_BA_SESSION:
4527                        Handle_AddBASession(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo);
4528                        break;
4529
4530                case HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS:
4531                        Handle_DelAllRxBASessions(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo);
4532                        break;
4533
4534                case HOST_IF_MSG_DEL_ALL_STA:
4535                        Handle_DelAllSta(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFDelAllSta);
4536                        break;
4537
4538                default:
4539                        PRINT_ER("[Host Interface] undefined Received Msg ID\n");
4540                        break;
4541                }
4542        }
4543
4544        PRINT_D(HOSTINF_DBG, "Releasing thread exit semaphore\n");
4545        up(&hSemHostIFthrdEnd);
4546        return 0;
4547}
4548
4549static void TimerCB_Scan(unsigned long arg)
4550{
4551        void *pvArg = (void *)arg;
4552        tstrHostIFmsg strHostIFmsg;
4553
4554        /* prepare the Timer Callback message */
4555        memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
4556        strHostIFmsg.drvHandler = pvArg;
4557        strHostIFmsg.u16MsgId = HOST_IF_MSG_SCAN_TIMER_FIRED;
4558
4559        /* send the message */
4560        WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
4561}
4562
4563static void TimerCB_Connect(unsigned long arg)
4564{
4565        void *pvArg = (void *)arg;
4566        tstrHostIFmsg strHostIFmsg;
4567
4568        /* prepare the Timer Callback message */
4569        memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
4570        strHostIFmsg.drvHandler = pvArg;
4571        strHostIFmsg.u16MsgId = HOST_IF_MSG_CONNECT_TIMER_FIRED;
4572
4573        /* send the message */
4574        WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
4575}
4576
4577
4578/**
4579 *  @brief              removes wpa/wpa2 keys
4580 *  @details    only in BSS STA mode if External Supplicant support is enabled.
4581 *                              removes all WPA/WPA2 station key entries from MAC hardware.
4582 *  @param[in,out] handle to the wifi driver
4583 *  @param[in]  6 bytes of Station Adress in the station entry table
4584 *  @return             Error code indicating success/failure
4585 *  @note
4586 *  @author             zsalah
4587 *  @date               8 March 2012
4588 *  @version            1.0
4589 */
4590/* Check implementation in core adding 9 bytes to the input! */
4591s32 host_int_remove_key(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8StaAddress)
4592{
4593        s32 s32Error = WILC_SUCCESS;
4594        tstrWID strWID;
4595        /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
4596
4597        strWID.u16WIDid = (u16)WID_REMOVE_KEY;
4598        strWID.enuWIDtype       = WID_STR;
4599        strWID.ps8WidVal        = (s8 *)pu8StaAddress;
4600        strWID.s32ValueSize = 6;
4601
4602        return s32Error;
4603
4604}
4605
4606/**
4607 *  @brief              removes WEP key
4608 *  @details    valid only in BSS STA mode if External Supplicant support is enabled.
4609 *                              remove a WEP key entry from MAC HW.
4610 *                              The BSS Station automatically finds the index of the entry using its
4611 *                              BSS ID and removes that entry from the MAC hardware.
4612 *  @param[in,out] handle to the wifi driver
4613 *  @param[in]  6 bytes of Station Adress in the station entry table
4614 *  @return             Error code indicating success/failure
4615 *  @note               NO need for the STA add since it is not used for processing
4616 *  @author             zsalah
4617 *  @date               8 March 2012
4618 *  @version            1.0
4619 */
4620s32 host_int_remove_wep_key(tstrWILC_WFIDrv *hWFIDrv, u8 u8keyIdx)
4621{
4622        s32 s32Error = WILC_SUCCESS;
4623        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4624        tstrHostIFmsg strHostIFmsg;
4625
4626
4627        if (pstrWFIDrv == NULL)
4628                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
4629
4630        /* prepare the Remove Wep Key Message */
4631        memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
4632
4633
4634        strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
4635        strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WEP;
4636        strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = REMOVEKEY;
4637        strHostIFmsg.drvHandler = hWFIDrv;
4638
4639
4640
4641        strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4642        uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8keyIdx;
4643
4644        /* send the message */
4645        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
4646        if (s32Error)
4647                PRINT_ER("Error in sending message queue : Request to remove WEP key\n");
4648        down(&(pstrWFIDrv->hSemTestKeyBlock));
4649
4650        WILC_CATCH(s32Error)
4651        {
4652
4653        }
4654        return s32Error;
4655}
4656
4657/**
4658 *  @brief              sets WEP default key
4659 *  @details    Sets the index of the WEP encryption key in use,
4660 *                              in the key table
4661 *  @param[in,out] handle to the wifi driver
4662 *  @param[in]  key index ( 0, 1, 2, 3)
4663 *  @return             Error code indicating success/failure
4664 *  @note
4665 *  @author             zsalah
4666 *  @date               8 March 2012
4667 *  @version            1.0
4668 */
4669s32 host_int_set_WEPDefaultKeyID(tstrWILC_WFIDrv *hWFIDrv, u8 u8Index)
4670{
4671        s32 s32Error = WILC_SUCCESS;
4672        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4673        tstrHostIFmsg strHostIFmsg;
4674
4675
4676        if (pstrWFIDrv == NULL)
4677                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
4678
4679        /* prepare the Key Message */
4680        memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
4681
4682
4683        strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
4684        strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WEP;
4685        strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = DEFAULTKEY;
4686        strHostIFmsg.drvHandler = hWFIDrv;
4687
4688
4689        strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4690        uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Index;
4691
4692        /* send the message */
4693        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
4694        if (s32Error)
4695                PRINT_ER("Error in sending message queue : Default key index\n");
4696        down(&(pstrWFIDrv->hSemTestKeyBlock));
4697
4698        WILC_CATCH(s32Error)
4699        {
4700
4701        }
4702
4703        return s32Error;
4704}
4705
4706/**
4707 *  @brief              sets WEP deafault key
4708 *  @details    valid only in BSS STA mode if External Supplicant support is enabled.
4709 *                              sets WEP key entry into MAC hardware when it receives the
4710 *                              corresponding request from NDIS.
4711 *  @param[in,out] handle to the wifi driver
4712 *  @param[in]  message containing WEP Key in the following format
4713 *|---------------------------------------|
4714 *|Key ID Value | Key Length |  Key             |
4715 *|-------------|------------|------------|
4716 |      1byte     |             1byte  | Key Length     |
4717 ||---------------------------------------|
4718 |
4719 *  @return             Error code indicating success/failure
4720 *  @note
4721 *  @author             zsalah
4722 *  @date               8 March 2012
4723 *  @version            1.0
4724 */
4725s32 host_int_add_wep_key_bss_sta(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8WepKey, u8 u8WepKeylen, u8 u8Keyidx)
4726{
4727
4728        s32 s32Error = WILC_SUCCESS;
4729        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4730        tstrHostIFmsg strHostIFmsg;
4731
4732        if (pstrWFIDrv == NULL)
4733                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
4734
4735
4736        /* prepare the Key Message */
4737        memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
4738
4739
4740        strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
4741        strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WEP;
4742        strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY;
4743        strHostIFmsg.drvHandler = hWFIDrv;
4744
4745
4746        strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4747        uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey = WILC_MALLOC(u8WepKeylen);
4748
4749        memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
4750                    pu8WepKey, u8WepKeylen);
4751
4752
4753        strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4754        uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen = (u8WepKeylen);
4755
4756        strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4757        uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Keyidx;
4758
4759        /* send the message */
4760        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
4761        if (s32Error)
4762                PRINT_ER("Error in sending message queue :WEP Key\n");
4763        down(&(pstrWFIDrv->hSemTestKeyBlock));
4764
4765        WILC_CATCH(s32Error)
4766        {
4767
4768        }
4769        return s32Error;
4770
4771}
4772
4773#ifdef WILC_AP_EXTERNAL_MLME
4774/**
4775 *
4776 *  @brief              host_int_add_wep_key_bss_ap
4777 *  @details    valid only in BSS AP mode if External Supplicant support is enabled.
4778 *                              sets WEP key entry into MAC hardware when it receives the
4779 *
4780 *                              corresponding request from NDIS.
4781 *  @param[in,out] handle to the wifi driver
4782 *
4783 *
4784 *  @return             Error code indicating success/failure
4785 *  @note
4786 *  @author             mdaftedar
4787 *  @date               28 FEB 2013
4788 *  @version            1.0
4789 */
4790s32 host_int_add_wep_key_bss_ap(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8WepKey, u8 u8WepKeylen, u8 u8Keyidx, u8 u8mode, AUTHTYPE_T tenuAuth_type)
4791{
4792
4793        s32 s32Error = WILC_SUCCESS;
4794        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4795        tstrHostIFmsg strHostIFmsg;
4796        u8 i;
4797
4798        if (pstrWFIDrv == NULL)
4799                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
4800
4801
4802        /* prepare the Key Message */
4803        memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
4804
4805        if (INFO) {
4806                for (i = 0; i < u8WepKeylen; i++)
4807                        PRINT_INFO(HOSTAPD_DBG, "KEY is %x\n", pu8WepKey[i]);
4808        }
4809        strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
4810        strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WEP;
4811        strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY_AP;
4812        strHostIFmsg.drvHandler = hWFIDrv;
4813
4814
4815        strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4816        uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey = WILC_MALLOC((u8WepKeylen));
4817
4818
4819        memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
4820                    pu8WepKey, (u8WepKeylen));
4821
4822
4823        strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4824        uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen = (u8WepKeylen);
4825
4826        strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4827        uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Keyidx;
4828
4829        strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4830        uniHostIFkeyAttr.strHostIFwepAttr.u8mode = u8mode;
4831
4832        strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4833        uniHostIFkeyAttr.strHostIFwepAttr.tenuAuth_type = tenuAuth_type;
4834        /* send the message */
4835        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
4836
4837        if (s32Error)
4838                PRINT_ER("Error in sending message queue :WEP Key\n");
4839        down(&(pstrWFIDrv->hSemTestKeyBlock));
4840
4841        WILC_CATCH(s32Error)
4842        {
4843
4844        }
4845        return s32Error;
4846
4847}
4848#endif
4849/**
4850 *  @brief              adds ptk Key
4851 *  @details
4852 *  @param[in,out] handle to the wifi driver
4853 *  @param[in]  message containing PTK Key in the following format
4854 *|-----------------------------------------------------------------------------|
4855 *|Station address | Key Length |       Temporal Key | Rx Michael Key |Tx Michael Key |
4856 *|----------------|------------|--------------|----------------|---------------|
4857 |      6 bytes          |      1byte     |   16 bytes   |        8 bytes         |        8 bytes        |
4858 ||-----------------------------------------------------------------------------|
4859 *  @return             Error code indicating success/failure
4860 *  @note
4861 *  @author             zsalah
4862 *  @date               8 March 2012
4863 *  @version            1.0
4864 */
4865s32 host_int_add_ptk(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8Ptk, u8 u8PtkKeylen,
4866                             const u8 *mac_addr, const u8 *pu8RxMic, const u8 *pu8TxMic, u8 mode, u8 u8Ciphermode, u8 u8Idx)
4867{
4868        s32 s32Error = WILC_SUCCESS;
4869        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4870        tstrHostIFmsg strHostIFmsg;
4871        u8 u8KeyLen = u8PtkKeylen;
4872        u32 i;
4873
4874        if (pstrWFIDrv == NULL)
4875                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
4876        if (pu8RxMic != NULL)
4877                u8KeyLen += RX_MIC_KEY_LEN;
4878        if (pu8TxMic != NULL)
4879                u8KeyLen += TX_MIC_KEY_LEN;
4880
4881        /* prepare the Key Message */
4882        memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
4883
4884
4885        strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
4886        strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WPAPtk;
4887        #ifdef WILC_AP_EXTERNAL_MLME
4888        if (mode == AP_MODE) {
4889                strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY_AP;
4890                strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4891                uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx = u8Idx;
4892        }
4893        #endif
4894        if (mode == STATION_MODE)
4895                strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY;
4896
4897
4898        strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4899        uniHostIFkeyAttr.strHostIFwpaAttr.pu8key = WILC_MALLOC(u8PtkKeylen);
4900
4901
4902        memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
4903                    pu8Ptk, u8PtkKeylen);
4904
4905        if (pu8RxMic != NULL) {
4906
4907                memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 16,
4908                            pu8RxMic, RX_MIC_KEY_LEN);
4909                if (INFO) {
4910                        for (i = 0; i < RX_MIC_KEY_LEN; i++)
4911                                PRINT_INFO(CFG80211_DBG, "PairwiseRx[%d] = %x\n", i, pu8RxMic[i]);
4912                }
4913        }
4914        if (pu8TxMic != NULL) {
4915
4916                memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 24,
4917                            pu8TxMic, TX_MIC_KEY_LEN);
4918                if (INFO) {
4919                        for (i = 0; i < TX_MIC_KEY_LEN; i++)
4920                                PRINT_INFO(CFG80211_DBG, "PairwiseTx[%d] = %x\n", i, pu8TxMic[i]);
4921                }
4922        }
4923
4924        strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4925        uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen = u8KeyLen;
4926
4927        strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4928        uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = u8Ciphermode;
4929        strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4930        uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr = mac_addr;
4931        strHostIFmsg.drvHandler = hWFIDrv;
4932
4933        /* send the message */
4934        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
4935
4936        if (s32Error)
4937                PRINT_ER("Error in sending message queue:  PTK Key\n");
4938
4939        /* ////////////// */
4940        down(&(pstrWFIDrv->hSemTestKeyBlock));
4941        /* /////// */
4942
4943        WILC_CATCH(s32Error)
4944        {
4945
4946        }
4947
4948        return s32Error;
4949}
4950
4951/**
4952 *  @brief              adds Rx GTk Key
4953 *  @details
4954 *  @param[in,out] handle to the wifi driver
4955 *  @param[in]  pu8RxGtk : contains temporal key | Rx Mic | Tx Mic
4956 *                              u8GtkKeylen :The total key length
4957 *
4958 *  @return             Error code indicating success/failure
4959 *  @note
4960 *  @author             zsalah
4961 *  @date               8 March 2012
4962 *  @version            1.0
4963 */
4964s32 host_int_add_rx_gtk(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8RxGtk, u8 u8GtkKeylen,
4965                                u8 u8KeyIdx, u32 u32KeyRSClen, const u8 *KeyRSC,
4966                                const u8 *pu8RxMic, const u8 *pu8TxMic, u8 mode, u8 u8Ciphermode)
4967{
4968        s32 s32Error = WILC_SUCCESS;
4969        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4970        tstrHostIFmsg strHostIFmsg;
4971        u8 u8KeyLen = u8GtkKeylen;
4972
4973        if (pstrWFIDrv == NULL)
4974                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
4975        /* prepare the Key Message */
4976        memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
4977
4978
4979        if (pu8RxMic != NULL)
4980                u8KeyLen += RX_MIC_KEY_LEN;
4981        if (pu8TxMic != NULL)
4982                u8KeyLen += TX_MIC_KEY_LEN;
4983        if (KeyRSC != NULL) {
4984                strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4985                uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq = WILC_MALLOC(u32KeyRSClen);
4986
4987                memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq,
4988                            KeyRSC, u32KeyRSClen);
4989        }
4990
4991
4992        strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
4993        strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WPARxGtk;
4994        strHostIFmsg.drvHandler = hWFIDrv;
4995
4996    #ifdef WILC_AP_EXTERNAL_MLME
4997        if (mode == AP_MODE) {
4998                strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY_AP;
4999                strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = u8Ciphermode;
5000        }
5001    #endif
5002        if (mode == STATION_MODE)
5003                strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY;
5004
5005
5006        strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
5007        uniHostIFkeyAttr.strHostIFwpaAttr.pu8key = WILC_MALLOC(u8KeyLen);
5008
5009        memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
5010                    pu8RxGtk, u8GtkKeylen);
5011
5012        if (pu8RxMic != NULL) {
5013
5014                memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 16,
5015                            pu8RxMic, RX_MIC_KEY_LEN);
5016
5017        }
5018        if (pu8TxMic != NULL) {
5019
5020                memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 24,
5021                            pu8TxMic, TX_MIC_KEY_LEN);
5022
5023        }
5024
5025        strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
5026        uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx = u8KeyIdx;
5027        strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
5028        uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen = u8KeyLen;
5029
5030        strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
5031        uniHostIFkeyAttr.strHostIFwpaAttr.u8seqlen = u32KeyRSClen;
5032
5033
5034
5035        /* send the message */
5036        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
5037        if (s32Error)
5038                PRINT_ER("Error in sending message queue:  RX GTK\n");
5039        /* ////////////// */
5040        down(&(pstrWFIDrv->hSemTestKeyBlock));
5041        /* /////// */
5042
5043        WILC_CATCH(s32Error)
5044        {
5045
5046        }
5047        return s32Error;
5048}
5049
5050/**
5051 *  @brief              host_int_set_pmkid_info
5052 *  @details    caches the pmkid valid only in BSS STA mode if External Supplicant
5053 *                              support is enabled. This Function sets the PMKID in firmware
5054 *                              when host drivr receives the corresponding request from NDIS.
5055 *                              The firmware then includes theset PMKID in the appropriate
5056 *                              management frames
5057 *  @param[in,out] handle to the wifi driver
5058 *  @param[in]  message containing PMKID Info in the following format
5059 *|-----------------------------------------------------------------|
5060 *|NumEntries | BSSID[1] | PMKID[1] |  ...      | BSSID[K] | PMKID[K] |
5061 *|-----------|------------|----------|-------|----------|----------|
5062 |         1    |               6        |   16         |  ...  |        6         |    16        |
5063 ||-----------------------------------------------------------------|
5064 *  @return             Error code indicating success/failure
5065 *  @note
5066 *  @author             zsalah
5067 *  @date               8 March 2012
5068 *  @version            1.0
5069 */
5070s32 host_int_set_pmkid_info(tstrWILC_WFIDrv *hWFIDrv, tstrHostIFpmkidAttr *pu8PmkidInfoArray)
5071{
5072        s32 s32Error = WILC_SUCCESS;
5073        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5074        tstrHostIFmsg strHostIFmsg;
5075        u32 i;
5076
5077
5078        if (pstrWFIDrv == NULL)
5079                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5080
5081        /* prepare the Key Message */
5082        memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5083
5084        strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
5085        strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = PMKSA;
5086        strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY;
5087        strHostIFmsg.drvHandler = hWFIDrv;
5088
5089        for (i = 0; i < pu8PmkidInfoArray->numpmkid; i++) {
5090
5091                memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].bssid, &pu8PmkidInfoArray->pmkidlist[i].bssid,
5092                            ETH_ALEN);
5093
5094                memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].pmkid, &pu8PmkidInfoArray->pmkidlist[i].pmkid,
5095                            PMKID_LEN);
5096        }
5097
5098        /* send the message */
5099        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
5100        if (s32Error)
5101                PRINT_ER(" Error in sending messagequeue: PMKID Info\n");
5102
5103        WILC_CATCH(s32Error)
5104        {
5105
5106        }
5107
5108        return s32Error;
5109}
5110
5111/**
5112 *  @brief              gets the cached the pmkid info
5113 *  @details    valid only in BSS STA mode if External Supplicant
5114 *                              support is enabled. This Function sets the PMKID in firmware
5115 *                              when host drivr receives the corresponding request from NDIS.
5116 *                              The firmware then includes theset PMKID in the appropriate
5117 *                              management frames
5118 *  @param[in,out] handle to the wifi driver,
5119 *                                message containing PMKID Info in the following format
5120 *|-----------------------------------------------------------------|
5121 *|NumEntries | BSSID[1] | PMKID[1] |  ...      | BSSID[K] | PMKID[K] |
5122 *|-----------|------------|----------|-------|----------|----------|
5123 |         1    |               6        |   16         |  ...  |        6         |    16        |
5124 ||-----------------------------------------------------------------|
5125 *  @param[in]
5126 *  @return             Error code indicating success/failure
5127 *  @note
5128 *  @author             zsalah
5129 *  @date               8 March 2012
5130 *  @version            1.0
5131 */
5132s32 host_int_get_pmkid_info(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8PmkidInfoArray,
5133                                    u32 u32PmkidInfoLen)
5134{
5135        s32 s32Error = WILC_SUCCESS;
5136        tstrWID strWID;
5137        /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5138
5139        strWID.u16WIDid = (u16)WID_PMKID_INFO;
5140        strWID.enuWIDtype       = WID_STR;
5141        strWID.s32ValueSize = u32PmkidInfoLen;
5142        strWID.ps8WidVal = pu8PmkidInfoArray;
5143
5144        return s32Error;
5145}
5146
5147/**
5148 *  @brief              sets the pass phrase
5149 *  @details    AP/STA mode. This function gives the pass phrase used to
5150 *                              generate the Pre-Shared Key when WPA/WPA2 is enabled
5151 *                              The length of the field can vary from 8 to 64 bytes,
5152 *                              the lower layer should get the
5153 *  @param[in,out] handle to the wifi driver,
5154 *  @param[in]   String containing PSK
5155 *  @return             Error code indicating success/failure
5156 *  @note
5157 *  @author             zsalah
5158 *  @date               8 March 2012
5159 *  @version            1.0
5160 */
5161s32 host_int_set_RSNAConfigPSKPassPhrase(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8PassPhrase,
5162                                                 u8 u8Psklength)
5163{
5164        s32 s32Error = WILC_SUCCESS;
5165        tstrWID strWID;
5166
5167        /*validating psk length*/
5168        if ((u8Psklength > 7) && (u8Psklength < 65)) {
5169                strWID.u16WIDid = (u16)WID_11I_PSK;
5170                strWID.enuWIDtype       = WID_STR;
5171                strWID.ps8WidVal        = pu8PassPhrase;
5172                strWID.s32ValueSize = u8Psklength;
5173        }
5174
5175        return s32Error;
5176}
5177/**
5178 *  @brief              host_int_get_MacAddress
5179 *  @details    gets mac address
5180 *  @param[in,out] handle to the wifi driver,
5181 *
5182 *  @return             Error code indicating success/failure
5183 *  @note
5184 *  @author             mdaftedar
5185 *  @date               19 April 2012
5186 *  @version            1.0
5187 */
5188s32 host_int_get_MacAddress(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8MacAddress)
5189{
5190        s32 s32Error = WILC_SUCCESS;
5191        tstrHostIFmsg strHostIFmsg;
5192
5193
5194        /* prepare the Message */
5195        memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5196
5197        strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_MAC_ADDRESS;
5198        strHostIFmsg.uniHostIFmsgBody.strHostIfGetMacAddress.u8MacAddress = pu8MacAddress;
5199        strHostIFmsg.drvHandler = hWFIDrv;
5200        /* send the message */
5201        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
5202        if (s32Error) {
5203                PRINT_ER("Failed to send get mac address\n");
5204                return WILC_FAIL;
5205        }
5206
5207        down(&hWaitResponse);
5208        return s32Error;
5209}
5210
5211/**
5212 *  @brief              host_int_set_MacAddress
5213 *  @details    sets mac address
5214 *  @param[in,out] handle to the wifi driver,
5215 *
5216 *  @return             Error code indicating success/failure
5217 *  @note
5218 *  @author             mabubakr
5219 *  @date               16 July 2012
5220 *  @version            1.0
5221 */
5222s32 host_int_set_MacAddress(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8MacAddress)
5223{
5224        s32 s32Error = WILC_SUCCESS;
5225        tstrHostIFmsg strHostIFmsg;
5226
5227        PRINT_D(GENERIC_DBG, "mac addr = %x:%x:%x\n", pu8MacAddress[0], pu8MacAddress[1], pu8MacAddress[2]);
5228
5229        /* prepare setting mac address message */
5230        memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5231        strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_MAC_ADDRESS;
5232        memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIfSetMacAddress.u8MacAddress, pu8MacAddress, ETH_ALEN);
5233        strHostIFmsg.drvHandler = hWFIDrv;
5234
5235        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
5236        if (s32Error) {
5237                PRINT_ER("Failed to send message queue: Set mac address\n");
5238                WILC_ERRORREPORT(s32Error, s32Error);
5239        }
5240        WILC_CATCH(s32Error)
5241        {
5242
5243        }
5244
5245        return s32Error;
5246
5247}
5248
5249/**
5250 *  @brief              host_int_get_RSNAConfigPSKPassPhrase
5251 *  @details    gets the pass phrase:AP/STA mode. This function gets the pass phrase used to
5252 *                              generate the Pre-Shared Key when WPA/WPA2 is enabled
5253 *                              The length of the field can vary from 8 to 64 bytes,
5254 *                              the lower layer should get the
5255 *  @param[in,out] handle to the wifi driver,
5256 *                                String containing PSK
5257 *  @return             Error code indicating success/failure
5258 *  @note
5259 *  @author             zsalah
5260 *  @date               8 March 2012
5261 *  @version            1.0
5262 */
5263s32 host_int_get_RSNAConfigPSKPassPhrase(tstrWILC_WFIDrv *hWFIDrv,
5264                                                 u8 *pu8PassPhrase, u8 u8Psklength)
5265{
5266        s32 s32Error = WILC_SUCCESS;
5267        tstrWID strWID;
5268        /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5269
5270        strWID.u16WIDid = (u16)WID_11I_PSK;
5271        strWID.enuWIDtype       = WID_STR;
5272        strWID.s32ValueSize = u8Psklength;
5273        strWID.ps8WidVal        = pu8PassPhrase;
5274
5275        return s32Error;
5276}
5277
5278/**
5279 *  @brief                      host_int_get_site_survey_results
5280 *  @details            gets the site survey results
5281 *  @param[in,out] handle to the wifi driver,
5282 *                                Message containing  site survey results in the
5283 *                                following format
5284 *|---------------------------------------------------|
5285 | MsgLength | fragNo.  | MsgBodyLength | MsgBody       |
5286 ||-----------|-----------|---------------|-----------|
5287 |       1              |         1             |               1               |        1              |
5288 | -----------------------------------------     |  ----------------
5289 |
5290 ||---------------------------------------|
5291 | Network1 | Netweork2 | ... | Network5 |
5292 ||---------------------------------------|
5293 |      44         |    44         | ... |       44             |
5294 | -------------------------- | ---------------------------------------
5295 |
5296 ||---------------------------------------------------------------------|
5297 | SSID | BSS Type | Channel | Security Status| BSSID | RSSI |Reserved |
5298 |
5299 |
5300 ||------|----------|---------|----------------|-------|------|---------|
5301 |  33  |        1        |       1             |               1                |        6      |       1      |        1        |
5302 ||---------------------------------------------------------------------|
5303 *  @return             Error code indicating success/failure
5304 *  @note
5305 *  @author             zsalah
5306 *  @date               8 March 2012
5307 *  @version            1.0
5308 */
5309#ifndef CONNECT_DIRECT
5310s32 host_int_get_site_survey_results(tstrWILC_WFIDrv *hWFIDrv,
5311                                             u8 ppu8RcvdSiteSurveyResults[][MAX_SURVEY_RESULT_FRAG_SIZE],
5312                                             u32 u32MaxSiteSrvyFragLen)
5313{
5314        s32 s32Error = WILC_SUCCESS;
5315        tstrWID astrWIDList[2];
5316        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5317
5318        astrWIDList[0].u16WIDid = (u16)WID_SITE_SURVEY_RESULTS;
5319        astrWIDList[0].enuWIDtype = WID_STR;
5320        astrWIDList[0].ps8WidVal = ppu8RcvdSiteSurveyResults[0];
5321        astrWIDList[0].s32ValueSize = u32MaxSiteSrvyFragLen;
5322
5323        astrWIDList[1].u16WIDid = (u16)WID_SITE_SURVEY_RESULTS;
5324        astrWIDList[1].enuWIDtype = WID_STR;
5325        astrWIDList[1].ps8WidVal = ppu8RcvdSiteSurveyResults[1];
5326        astrWIDList[1].s32ValueSize = u32MaxSiteSrvyFragLen;
5327
5328        s32Error = SendConfigPkt(GET_CFG, astrWIDList, 2, true, (u32)pstrWFIDrv);
5329
5330        /*get the value by searching the local copy*/
5331        if (s32Error) {
5332                PRINT_ER("Failed to send config packet to get survey results\n");
5333                WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
5334        }
5335
5336        WILC_CATCH(s32Error)
5337        {
5338
5339        }
5340
5341        return s32Error;
5342}
5343#endif
5344
5345/**
5346 *  @brief              sets a start scan request
5347 *  @details
5348 *  @param[in,out] handle to the wifi driver,
5349 *  @param[in]  Scan Source one of the following values
5350 *                              DEFAULT_SCAN        0
5351 *                              USER_SCAN           BIT0
5352 *                              OBSS_PERIODIC_SCAN  BIT1
5353 *                              OBSS_ONETIME_SCAN   BIT2
5354 *  @return             Error code indicating success/failure
5355 *  @note
5356 *  @author             zsalah
5357 *  @date               8 March 2012
5358 *  @version            1.0
5359 */
5360s32 host_int_set_start_scan_req(tstrWILC_WFIDrv *hWFIDrv, u8 scanSource)
5361{
5362        s32 s32Error = WILC_SUCCESS;
5363        tstrWID strWID;
5364        /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5365
5366        strWID.u16WIDid = (u16)WID_START_SCAN_REQ;
5367        strWID.enuWIDtype = WID_CHAR;
5368        strWID.ps8WidVal = (s8 *)&scanSource;
5369        strWID.s32ValueSize = sizeof(char);
5370
5371        return s32Error;
5372}
5373
5374/**
5375 *  @brief                      host_int_get_start_scan_req
5376 *  @details            gets a start scan request
5377 *  @param[in,out] handle to the wifi driver,
5378 *  @param[in]  Scan Source one of the following values
5379 *                              DEFAULT_SCAN        0
5380 *                              USER_SCAN           BIT0
5381 *                              OBSS_PERIODIC_SCAN  BIT1
5382 *                              OBSS_ONETIME_SCAN   BIT2
5383 *  @return             Error code indicating success/failure
5384 *  @note
5385 *  @author             zsalah
5386 *  @date               8 March 2012
5387 *  @version            1.0
5388 */
5389
5390s32 host_int_get_start_scan_req(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8ScanSource)
5391{
5392        s32 s32Error = WILC_SUCCESS;
5393        tstrWID strWID;
5394        /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5395
5396        strWID.u16WIDid = (u16)WID_START_SCAN_REQ;
5397        strWID.enuWIDtype = WID_CHAR;
5398        strWID.ps8WidVal = (s8 *)pu8ScanSource;
5399        strWID.s32ValueSize = sizeof(char);
5400
5401        return s32Error;
5402}
5403
5404/**
5405 *  @brief                      host_int_set_join_req
5406 *  @details            sets a join request
5407 *  @param[in,out] handle to the wifi driver,
5408 *  @param[in]  Index of the bss descriptor
5409 *  @return             Error code indicating success/failure
5410 *  @note
5411 *  @author             zsalah
5412 *  @date               8 March 2012
5413 *  @version            1.0
5414 */
5415s32 host_int_set_join_req(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8bssid,
5416                                  const u8 *pu8ssid, size_t ssidLen,
5417                                  const u8 *pu8IEs, size_t IEsLen,
5418                                  tWILCpfConnectResult pfConnectResult, void *pvUserArg,
5419                                  u8 u8security, AUTHTYPE_T tenuAuth_type,
5420                                  u8 u8channel,
5421                                  void *pJoinParams)
5422{
5423        s32 s32Error = WILC_SUCCESS;
5424        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5425        tstrHostIFmsg strHostIFmsg;
5426        tenuScanConnTimer enuScanConnTimer;
5427
5428        if (pstrWFIDrv == NULL || pfConnectResult == NULL)
5429                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5430
5431        if (hWFIDrv == NULL) {
5432                PRINT_ER("Driver not initialized: gWFiDrvHandle = NULL\n");
5433                WILC_ERRORREPORT(s32Error, WILC_FAIL);
5434        }
5435
5436        if (pJoinParams == NULL) {
5437                PRINT_ER("Unable to Join - JoinParams is NULL\n");
5438                WILC_ERRORREPORT(s32Error, WILC_FAIL);
5439
5440        }
5441/*
5442 *      if(gWFiDrvHandle->strWILC_UsrScanReq.u32RcvdChCount == 0)
5443 *      {
5444 *              PRINT_ER("No scan results exist: Scanning should be done\n");
5445 *              WILC_ERRORREPORT(s32Error, WILC_FAIL);
5446 *      }
5447 */
5448        /* prepare the Connect Message */
5449        memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5450
5451        strHostIFmsg.u16MsgId = HOST_IF_MSG_CONNECT;
5452
5453        strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.u8security = u8security;
5454        strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.tenuAuth_type = tenuAuth_type;
5455        strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.u8channel = u8channel;
5456        strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pfConnectResult = pfConnectResult;
5457        strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pvUserArg = pvUserArg;
5458        strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pJoinParams = pJoinParams;
5459        strHostIFmsg.drvHandler = hWFIDrv;
5460
5461        if (pu8bssid != NULL) {
5462                strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8bssid = WILC_MALLOC(6); /* will be deallocated by the receiving thread */
5463                memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8bssid,
5464                            pu8bssid, 6);
5465        }
5466
5467        if (pu8ssid != NULL) {
5468                strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.ssidLen = ssidLen;
5469                strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8ssid = WILC_MALLOC(ssidLen); /* will be deallocated by the receiving thread */
5470                memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8ssid,
5471
5472                            pu8ssid, ssidLen);
5473        }
5474
5475        if (pu8IEs != NULL) {
5476                strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.IEsLen = IEsLen;
5477                strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8IEs = WILC_MALLOC(IEsLen); /* will be deallocated by the receiving thread */
5478                memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8IEs,
5479                            pu8IEs, IEsLen);
5480        }
5481        if (pstrWFIDrv->enuHostIFstate < HOST_IF_CONNECTING)
5482                pstrWFIDrv->enuHostIFstate = HOST_IF_CONNECTING;
5483        else
5484                PRINT_D(GENERIC_DBG, "Don't set state to 'connecting' as state is %d\n", pstrWFIDrv->enuHostIFstate);
5485
5486        /* send the message */
5487        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
5488        if (s32Error) {
5489                PRINT_ER("Failed to send message queue: Set join request\n");
5490                WILC_ERRORREPORT(s32Error, WILC_FAIL);
5491        }
5492
5493        enuScanConnTimer = CONNECT_TIMER;
5494        pstrWFIDrv->hConnectTimer.data = (unsigned long)hWFIDrv;
5495        mod_timer(&pstrWFIDrv->hConnectTimer,
5496                  jiffies + msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT));
5497
5498        WILC_CATCH(s32Error)
5499        {
5500
5501        }
5502
5503        return s32Error;
5504}
5505
5506/**
5507 *  @brief              Flush a join request parameters to FW, but actual connection
5508 *  @details    The function is called in situation where WILC is connected to AP and
5509 *                      required to switch to hybrid FW for P2P connection
5510 *  @param[in] handle to the wifi driver,
5511 *  @return     Error code indicating success/failure
5512 *  @note
5513 *  @author     Amr Abdel-Moghny
5514 *  @date               19 DEC 2013
5515 *  @version    8.0
5516 */
5517
5518s32 host_int_flush_join_req(tstrWILC_WFIDrv *hWFIDrv)
5519{
5520        s32 s32Error = WILC_SUCCESS;
5521        tstrHostIFmsg strHostIFmsg;
5522
5523        if (!gu8FlushedJoinReq) {
5524                s32Error = WILC_FAIL;
5525                return s32Error;
5526        }
5527
5528
5529        if (hWFIDrv  == NULL)
5530                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5531
5532
5533        strHostIFmsg.u16MsgId = HOST_IF_MSG_FLUSH_CONNECT;
5534        strHostIFmsg.drvHandler = hWFIDrv;
5535
5536        /* send the message */
5537        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
5538        if (s32Error) {
5539                PRINT_ER("Failed to send message queue: Flush join request\n");
5540                WILC_ERRORREPORT(s32Error, WILC_FAIL);
5541        }
5542
5543        WILC_CATCH(s32Error)
5544        {
5545
5546        }
5547        return s32Error;
5548}
5549
5550/**
5551 *  @brief                      host_int_disconnect
5552 *  @details            disconnects from the currently associated network
5553 *  @param[in,out] handle to the wifi driver,
5554 *  @param[in]  Reason Code of the Disconnection
5555 *  @return             Error code indicating success/failure
5556 *  @note
5557 *  @author             zsalah
5558 *  @date               8 March 2012
5559 *  @version            1.0
5560 */
5561s32 host_int_disconnect(tstrWILC_WFIDrv *hWFIDrv, u16 u16ReasonCode)
5562{
5563        s32 s32Error = WILC_SUCCESS;
5564        tstrHostIFmsg strHostIFmsg;
5565        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5566
5567        if (pstrWFIDrv == NULL) {
5568                PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
5569                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5570        }
5571
5572        if (pstrWFIDrv == NULL) {
5573                PRINT_ER("gWFiDrvHandle = NULL\n");
5574                WILC_ERRORREPORT(s32Error, WILC_FAIL);
5575        }
5576
5577        /* prepare the Disconnect Message */
5578        memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5579
5580        strHostIFmsg.u16MsgId = HOST_IF_MSG_DISCONNECT;
5581        strHostIFmsg.drvHandler = hWFIDrv;
5582
5583        /* send the message */
5584        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
5585        if (s32Error)
5586                PRINT_ER("Failed to send message queue: disconnect\n");
5587        /* ////////////// */
5588        down(&(pstrWFIDrv->hSemTestDisconnectBlock));
5589        /* /////// */
5590
5591        WILC_CATCH(s32Error)
5592        {
5593
5594        }
5595
5596        return s32Error;
5597}
5598
5599/**
5600 *  @brief              host_int_disconnect_station
5601 *  @details     disconnects a sta
5602 *  @param[in,out] handle to the wifi driver,
5603 *  @param[in]  Association Id of the station to be disconnected
5604 *  @return             Error code indicating success/failure
5605 *  @note
5606 *  @author             zsalah
5607 *  @date               8 March 2012
5608 *  @version            1.0
5609 */
5610s32 host_int_disconnect_station(tstrWILC_WFIDrv *hWFIDrv, u8 assoc_id)
5611{
5612        s32 s32Error = WILC_SUCCESS;
5613        tstrWID strWID;
5614        /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5615
5616        strWID.u16WIDid = (u16)WID_DISCONNECT;
5617        strWID.enuWIDtype = WID_CHAR;
5618        strWID.ps8WidVal = (s8 *)&assoc_id;
5619        strWID.s32ValueSize = sizeof(char);
5620
5621        return s32Error;
5622}
5623
5624/**
5625 *  @brief                      host_int_get_assoc_req_info
5626 *  @details            gets a Association request info
5627 *  @param[in,out] handle to the wifi driver,
5628 *                              Message containg assoc. req info in the following format
5629 * ------------------------------------------------------------------------
5630 |                        Management Frame Format                    |
5631 ||-------------------------------------------------------------------|
5632 ||Frame Control|Duration|DA|SA|BSSID|Sequence Control|Frame Body|FCS |
5633 ||-------------|--------|--|--|-----|----------------|----------|----|
5634 | 2           |2       |6 |6 |6    |           2       |0 - 2312  | 4  |
5635 ||-------------------------------------------------------------------|
5636 |                                                                   |
5637 |             Association Request Frame - Frame Body                |
5638 ||-------------------------------------------------------------------|
5639 | Capability Information | Listen Interval | SSID | Supported Rates |
5640 ||------------------------|-----------------|------|-----------------|
5641 |                      2            |           2         | 2-34 |             3-10        |
5642 | ---------------------------------------------------------------------
5643 *  @return             Error code indicating success/failure
5644 *  @note
5645 *  @author             zsalah
5646 *  @date               8 March 2012
5647 *  @version            1.0
5648 */
5649
5650s32 host_int_get_assoc_req_info(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8AssocReqInfo,
5651                                        u32 u32AssocReqInfoLen)
5652{
5653        s32 s32Error = WILC_SUCCESS;
5654        tstrWID strWID;
5655        /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5656
5657        strWID.u16WIDid = (u16)WID_ASSOC_REQ_INFO;
5658        strWID.enuWIDtype = WID_STR;
5659        strWID.ps8WidVal = pu8AssocReqInfo;
5660        strWID.s32ValueSize = u32AssocReqInfoLen;
5661
5662
5663        return s32Error;
5664}
5665
5666/**
5667 *  @brief              gets a Association Response info
5668 *  @details
5669 *  @param[in,out] handle to the wifi driver,
5670 *                              Message containg assoc. resp info
5671 *  @return             Error code indicating success/failure
5672 *  @note
5673 *  @author             zsalah
5674 *  @date               8 March 2012
5675 *  @version            1.0
5676 */
5677s32 host_int_get_assoc_res_info(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8AssocRespInfo,
5678                                        u32 u32MaxAssocRespInfoLen, u32 *pu32RcvdAssocRespInfoLen)
5679{
5680        s32 s32Error = WILC_SUCCESS;
5681        tstrWID strWID;
5682        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5683
5684        if (pstrWFIDrv == NULL) {
5685                PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
5686                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5687        }
5688
5689        strWID.u16WIDid = (u16)WID_ASSOC_RES_INFO;
5690        strWID.enuWIDtype = WID_STR;
5691        strWID.ps8WidVal = pu8AssocRespInfo;
5692        strWID.s32ValueSize = u32MaxAssocRespInfoLen;
5693
5694
5695        /* Sending Configuration packet */
5696        s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
5697        if (s32Error) {
5698                PRINT_ER("Failed to send association response config packet\n");
5699                *pu32RcvdAssocRespInfoLen = 0;
5700                WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
5701        } else {
5702                *pu32RcvdAssocRespInfoLen = strWID.s32ValueSize;
5703        }
5704
5705        WILC_CATCH(s32Error)
5706        {
5707
5708        }
5709        return s32Error;
5710}
5711
5712/**
5713 *  @brief              gets a Association Response info
5714 *  @details    Valid only in STA mode. This function gives the RSSI
5715 *                              values observed in all the channels at the time of scanning.
5716 *                              The length of the field is 1 greater that the total number of
5717 *                              channels supported. Byte 0 contains the number of channels while
5718 *                              each of Byte N contains the observed RSSI value for the channel index N.
5719 *  @param[in,out] handle to the wifi driver,
5720 *                              array of scanned channels' RSSI
5721 *  @return             Error code indicating success/failure
5722 *  @note
5723 *  @author             zsalah
5724 *  @date               8 March 2012
5725 *  @version            1.0
5726 */
5727s32 host_int_get_rx_power_level(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8RxPowerLevel,
5728                                        u32 u32RxPowerLevelLen)
5729{
5730        s32 s32Error = WILC_SUCCESS;
5731        tstrWID strWID;
5732        /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5733
5734        strWID.u16WIDid = (u16)WID_RX_POWER_LEVEL;
5735        strWID.enuWIDtype = WID_STR;
5736        strWID.ps8WidVal = pu8RxPowerLevel;
5737        strWID.s32ValueSize = u32RxPowerLevelLen;
5738
5739
5740        return s32Error;
5741}
5742
5743/**
5744 *  @brief              sets a channel
5745 *  @details
5746 *  @param[in,out] handle to the wifi driver,
5747 *  @param[in]  Index of the channel to be set
5748 *|-------------------------------------------------------------------|
5749 |          CHANNEL1      CHANNEL2 ....                      CHANNEL14  |
5750 |  Input:         1             2                                                  14  |
5751 ||-------------------------------------------------------------------|
5752 *  @return             Error code indicating success/failure
5753 *  @note
5754 *  @author             zsalah
5755 *  @date               8 March 2012
5756 *  @version            1.0
5757 */
5758s32 host_int_set_mac_chnl_num(tstrWILC_WFIDrv *hWFIDrv, u8 u8ChNum)
5759{
5760        s32 s32Error = WILC_SUCCESS;
5761        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5762        tstrHostIFmsg strHostIFmsg;
5763
5764        if (pstrWFIDrv == NULL)
5765                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5766
5767        /* prepare the set channel message */
5768        memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5769        strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_CHANNEL;
5770        strHostIFmsg.uniHostIFmsgBody.strHostIFSetChan.u8SetChan = u8ChNum;
5771        strHostIFmsg.drvHandler = hWFIDrv;
5772
5773        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
5774        if (s32Error)
5775                WILC_ERRORREPORT(s32Error, s32Error);
5776        WILC_CATCH(s32Error)
5777        {
5778
5779        }
5780
5781        return s32Error;
5782}
5783
5784
5785s32 host_int_wait_msg_queue_idle(void)
5786{
5787        s32 s32Error = WILC_SUCCESS;
5788
5789        tstrHostIFmsg strHostIFmsg;
5790
5791        /* prepare the set driver handler message */
5792
5793        memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5794        strHostIFmsg.u16MsgId = HOST_IF_MSG_Q_IDLE;
5795        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
5796        if (s32Error)
5797                WILC_ERRORREPORT(s32Error, s32Error);
5798        WILC_CATCH(s32Error)
5799        {
5800
5801        }
5802
5803        /* wait untill MSG Q is empty */
5804        down(&hWaitResponse);
5805
5806        return s32Error;
5807
5808}
5809
5810s32 host_int_set_wfi_drv_handler(tstrWILC_WFIDrv *u32address)
5811{
5812        s32 s32Error = WILC_SUCCESS;
5813
5814        tstrHostIFmsg strHostIFmsg;
5815
5816
5817        /* prepare the set driver handler message */
5818
5819        memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5820        strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_WFIDRV_HANDLER;
5821        strHostIFmsg.uniHostIFmsgBody.strHostIfSetDrvHandler.u32Address = u32address;
5822        /* strHostIFmsg.drvHandler=hWFIDrv; */
5823
5824        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
5825        if (s32Error)
5826                WILC_ERRORREPORT(s32Error, s32Error);
5827        WILC_CATCH(s32Error)
5828        {
5829
5830        }
5831
5832        return s32Error;
5833}
5834
5835
5836
5837s32 host_int_set_operation_mode(tstrWILC_WFIDrv *hWFIDrv, u32 u32mode)
5838{
5839        s32 s32Error = WILC_SUCCESS;
5840
5841        tstrHostIFmsg strHostIFmsg;
5842
5843
5844        /* prepare the set driver handler message */
5845
5846        memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5847        strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_OPERATION_MODE;
5848        strHostIFmsg.uniHostIFmsgBody.strHostIfSetOperationMode.u32Mode = u32mode;
5849        strHostIFmsg.drvHandler = hWFIDrv;
5850
5851        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
5852        if (s32Error)
5853                WILC_ERRORREPORT(s32Error, s32Error);
5854        WILC_CATCH(s32Error)
5855        {
5856
5857        }
5858
5859        return s32Error;
5860}
5861
5862/**
5863 *  @brief              gets the current channel index
5864 *  @details
5865 *  @param[in,out] handle to the wifi driver,
5866 *                              current channel index
5867 *|-----------------------------------------------------------------------|
5868 |          CHANNEL1      CHANNEL2 ....                     CHANNEL14   |
5869 |  Input:         1             2                                 14   |
5870 ||-----------------------------------------------------------------------|
5871 *  @return             Error code indicating success/failure
5872 *  @note
5873 *  @author             zsalah
5874 *  @date               8 March 2012
5875 *  @version            1.0
5876 */
5877s32 host_int_get_host_chnl_num(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8ChNo)
5878{
5879        s32 s32Error = WILC_SUCCESS;
5880        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5881        tstrHostIFmsg strHostIFmsg;
5882
5883        if (pstrWFIDrv == NULL) {
5884                PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
5885                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5886        }
5887
5888        /* prepare the Get Channel Message */
5889        memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5890
5891        strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_CHNL;
5892        strHostIFmsg.drvHandler = hWFIDrv;
5893
5894        /* send the message */
5895        s32Error =      WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
5896        if (s32Error)
5897                PRINT_ER("Failed to send get host channel param's message queue ");
5898        down(&(pstrWFIDrv->hSemGetCHNL));
5899        /* gu8Chnl = 11; */
5900
5901        *pu8ChNo = gu8Chnl;
5902
5903        WILC_CATCH(s32Error)
5904        {
5905        }
5906
5907        return s32Error;
5908
5909
5910}
5911
5912
5913/**
5914 *  @brief                       host_int_test_set_int_wid
5915 *  @details             Test function for setting wids
5916 *  @param[in,out]   WILC_WFIDrvHandle hWFIDrv, u32 u32TestMemAddr
5917 *  @return              Error code indicating success/failure
5918 *  @note
5919 *  @author             zsalah
5920 *  @date               8 March 2012
5921 *  @version            1.0
5922 */
5923s32 host_int_test_set_int_wid(tstrWILC_WFIDrv *hWFIDrv, u32 u32TestMemAddr)
5924{
5925        s32 s32Error = WILC_SUCCESS;
5926        tstrWID strWID;
5927        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5928
5929
5930        if (pstrWFIDrv == NULL) {
5931                PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
5932                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5933        }
5934
5935        /*prepare configuration packet*/
5936        strWID.u16WIDid = (u16)WID_MEMORY_ADDRESS;
5937        strWID.enuWIDtype = WID_INT;
5938        strWID.ps8WidVal = (char *)&u32TestMemAddr;
5939        strWID.s32ValueSize = sizeof(u32);
5940
5941        /*Sending Cfg*/
5942        s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
5943        if (s32Error) {
5944                PRINT_ER("Test Function: Failed to set wid value\n");
5945                WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
5946        } else {
5947                PRINT_D(HOSTINF_DBG, "Successfully set wid value\n");
5948
5949        }
5950
5951        WILC_CATCH(s32Error)
5952        {
5953
5954        }
5955        return s32Error;
5956}
5957
5958#ifdef WILC_AP_EXTERNAL_MLME
5959/**
5960 *  @brief              host_int_get_inactive_time
5961 *  @details
5962 *  @param[in,out] handle to the wifi driver,
5963 *                              current sta macaddress, inactive_time
5964 *  @return
5965 *  @note
5966 *  @author
5967 *  @date
5968 *  @version            1.0
5969 */
5970s32 host_int_get_inactive_time(tstrWILC_WFIDrv *hWFIDrv, const u8 *mac, u32 *pu32InactiveTime)
5971{
5972        s32 s32Error = WILC_SUCCESS;
5973        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5974        tstrHostIFmsg strHostIFmsg;
5975
5976        if (pstrWFIDrv == NULL) {
5977                PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
5978                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5979        }
5980
5981        memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5982
5983
5984        memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIfStaInactiveT.mac,
5985                    mac, ETH_ALEN);
5986
5987        strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_INACTIVETIME;
5988        strHostIFmsg.drvHandler = hWFIDrv;
5989
5990        /* send the message */
5991        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
5992        if (s32Error)
5993                PRINT_ER("Failed to send get host channel param's message queue ");
5994
5995        down(&(pstrWFIDrv->hSemInactiveTime));
5996
5997        *pu32InactiveTime = gu32InactiveTime;
5998
5999        WILC_CATCH(s32Error)
6000        {
6001        }
6002
6003        return s32Error;
6004}
6005#endif
6006/**
6007 *  @brief              host_int_test_get_int_wid
6008 *  @details    Test function for getting wids
6009 *  @param[in,out] WILC_WFIDrvHandle hWFIDrv, u32* pu32TestMemAddr
6010 *  @return             Error code indicating success/failure
6011 *  @note
6012 *  @author             zsalah
6013 *  @date               8 March 2012
6014 *  @version            1.0
6015 */
6016s32 host_int_test_get_int_wid(tstrWILC_WFIDrv *hWFIDrv, u32 *pu32TestMemAddr)
6017{
6018
6019        s32 s32Error = WILC_SUCCESS;
6020        tstrWID strWID;
6021        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6022
6023
6024        if (pstrWFIDrv == NULL) {
6025                PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
6026                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
6027        }
6028
6029        strWID.u16WIDid = (u16)WID_MEMORY_ADDRESS;
6030        strWID.enuWIDtype = WID_INT;
6031        strWID.ps8WidVal = (s8 *)pu32TestMemAddr;
6032        strWID.s32ValueSize = sizeof(u32);
6033
6034        s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
6035        /*get the value by searching the local copy*/
6036        if (s32Error) {
6037                PRINT_ER("Test Function: Failed to get wid value\n");
6038                WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
6039        } else {
6040                PRINT_D(HOSTINF_DBG, "Successfully got wid value\n");
6041
6042        }
6043
6044        WILC_CATCH(s32Error)
6045        {
6046
6047        }
6048        return s32Error;
6049}
6050
6051
6052/**
6053 *  @brief              host_int_get_rssi
6054 *  @details    gets the currently maintained RSSI value for the station.
6055 *                              The received signal strength value in dB.
6056 *                              The range of valid values is -128 to 0.
6057 *  @param[in,out] handle to the wifi driver,
6058 *                              rssi value in dB
6059 *  @return             Error code indicating success/failure
6060 *  @note
6061 *  @author             zsalah
6062 *  @date               8 March 2012
6063 *  @version            1.0
6064 */
6065s32 host_int_get_rssi(tstrWILC_WFIDrv *hWFIDrv, s8 *ps8Rssi)
6066{
6067        s32 s32Error = WILC_SUCCESS;
6068        tstrHostIFmsg strHostIFmsg;
6069        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6070
6071
6072        /* prepare the Get RSSI Message */
6073        memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6074
6075        strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_RSSI;
6076        strHostIFmsg.drvHandler = hWFIDrv;
6077
6078        /* send the message */
6079        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
6080        if (s32Error) {
6081                PRINT_ER("Failed to send get host channel param's message queue ");
6082                return WILC_FAIL;
6083        }
6084
6085        down(&(pstrWFIDrv->hSemGetRSSI));
6086
6087
6088        if (ps8Rssi == NULL) {
6089                PRINT_ER("RSS pointer value is null");
6090                return WILC_FAIL;
6091        }
6092
6093
6094        *ps8Rssi = gs8Rssi;
6095
6096
6097        return s32Error;
6098}
6099
6100s32 host_int_get_link_speed(tstrWILC_WFIDrv *hWFIDrv, s8 *ps8lnkspd)
6101{
6102        tstrHostIFmsg strHostIFmsg;
6103        s32 s32Error = WILC_SUCCESS;
6104
6105        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6106
6107
6108
6109        /* prepare the Get LINKSPEED Message */
6110        memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6111
6112        strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_LINKSPEED;
6113        strHostIFmsg.drvHandler = hWFIDrv;
6114
6115        /* send the message */
6116        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
6117        if (s32Error) {
6118                PRINT_ER("Failed to send GET_LINKSPEED to message queue ");
6119                return WILC_FAIL;
6120        }
6121
6122        down(&(pstrWFIDrv->hSemGetLINKSPEED));
6123
6124
6125        if (ps8lnkspd == NULL) {
6126                PRINT_ER("LINKSPEED pointer value is null");
6127                return WILC_FAIL;
6128        }
6129
6130
6131        *ps8lnkspd = gs8lnkspd;
6132
6133
6134        return s32Error;
6135}
6136
6137s32 host_int_get_statistics(tstrWILC_WFIDrv *hWFIDrv, tstrStatistics *pstrStatistics)
6138{
6139        s32 s32Error = WILC_SUCCESS;
6140        tstrHostIFmsg strHostIFmsg;
6141
6142
6143        /* prepare the Get RSSI Message */
6144        memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6145
6146        strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_STATISTICS;
6147        strHostIFmsg.uniHostIFmsgBody.pUserData = (char *)pstrStatistics;
6148        strHostIFmsg.drvHandler = hWFIDrv;
6149        /* send the message */
6150        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
6151        if (s32Error) {
6152                PRINT_ER("Failed to send get host channel param's message queue ");
6153                return WILC_FAIL;
6154        }
6155
6156        down(&hWaitResponse);
6157        return s32Error;
6158}
6159
6160
6161/**
6162 *  @brief              host_int_scan
6163 *  @details    scans a set of channels
6164 *  @param[in,out] handle to the wifi driver,
6165 *  @param[in]  Scan source
6166 *                              Scan Type       PASSIVE_SCAN = 0,
6167 *                                                      ACTIVE_SCAN  = 1
6168 *                              Channels Array
6169 *                              Channels Array length
6170 *                              Scan Callback function
6171 *  @return             Error code indicating success/failure
6172 *  @note
6173 *  @author             zsalah
6174 *  @date               8 March 2012
6175 *  @version            1.0
6176 */
6177s32 host_int_scan(tstrWILC_WFIDrv *hWFIDrv, u8 u8ScanSource,
6178                          u8 u8ScanType, u8 *pu8ChnlFreqList,
6179                          u8 u8ChnlListLen, const u8 *pu8IEs,
6180                          size_t IEsLen, tWILCpfScanResult ScanResult,
6181                          void *pvUserArg, tstrHiddenNetwork  *pstrHiddenNetwork)
6182{
6183        s32 s32Error = WILC_SUCCESS;
6184        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6185        tstrHostIFmsg strHostIFmsg;
6186        tenuScanConnTimer enuScanConnTimer;
6187
6188        if (pstrWFIDrv == NULL || ScanResult == NULL)
6189                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
6190
6191
6192        /* prepare the Scan Message */
6193        memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6194
6195        strHostIFmsg.u16MsgId = HOST_IF_MSG_SCAN;
6196
6197        if (pstrHiddenNetwork != NULL) {
6198                strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.strHiddenNetwork.pstrHiddenNetworkInfo = pstrHiddenNetwork->pstrHiddenNetworkInfo;
6199                strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.strHiddenNetwork.u8ssidnum = pstrHiddenNetwork->u8ssidnum;
6200
6201        } else
6202                PRINT_D(HOSTINF_DBG, "pstrHiddenNetwork IS EQUAL TO NULL\n");
6203
6204        strHostIFmsg.drvHandler = hWFIDrv;
6205        strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.u8ScanSource = u8ScanSource;
6206        strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.u8ScanType = u8ScanType;
6207        strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pfScanResult = ScanResult;
6208        strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pvUserArg = pvUserArg;
6209
6210        strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.u8ChnlListLen = u8ChnlListLen;
6211        strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pu8ChnlFreqList = WILC_MALLOC(u8ChnlListLen);        /* will be deallocated by the receiving thread */
6212        memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pu8ChnlFreqList,
6213                    pu8ChnlFreqList, u8ChnlListLen);
6214
6215        strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.IEsLen = IEsLen;
6216        strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pu8IEs = WILC_MALLOC(IEsLen);        /* will be deallocated by the receiving thread */
6217        memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pu8IEs,
6218                    pu8IEs, IEsLen);
6219
6220        /* send the message */
6221        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
6222        if (s32Error) {
6223                PRINT_ER("Error in sending message queue scanning parameters: Error(%d)\n", s32Error);
6224                WILC_ERRORREPORT(s32Error, WILC_FAIL);
6225        }
6226
6227        enuScanConnTimer = SCAN_TIMER;
6228        PRINT_D(HOSTINF_DBG, ">> Starting the SCAN timer\n");
6229        pstrWFIDrv->hScanTimer.data = (unsigned long)hWFIDrv;
6230        mod_timer(&pstrWFIDrv->hScanTimer,
6231                  jiffies + msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT));
6232
6233        WILC_CATCH(s32Error)
6234        {
6235
6236        }
6237        return s32Error;
6238
6239}
6240/**
6241 *  @brief                      hif_set_cfg
6242 *  @details            sets configuration wids values
6243 *  @param[in,out] handle to the wifi driver,
6244 *  @param[in]  WID, WID value
6245 *  @return             Error code indicating success/failure
6246 *  @note
6247 *  @author             zsalah
6248 *  @date               8 March 2012
6249 *  @version            1.0
6250 */
6251s32 hif_set_cfg(tstrWILC_WFIDrv *hWFIDrv, tstrCfgParamVal *pstrCfgParamVal)
6252{
6253
6254        s32 s32Error = WILC_SUCCESS;
6255        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6256
6257        tstrHostIFmsg strHostIFmsg;
6258
6259
6260        if (pstrWFIDrv == NULL)
6261                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
6262        /* prepare the WiphyParams Message */
6263        memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6264        strHostIFmsg.u16MsgId = HOST_IF_MSG_CFG_PARAMS;
6265        strHostIFmsg.uniHostIFmsgBody.strHostIFCfgParamAttr.pstrCfgParamVal = *pstrCfgParamVal;
6266        strHostIFmsg.drvHandler = hWFIDrv;
6267
6268        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
6269
6270        WILC_CATCH(s32Error)
6271        {
6272        }
6273
6274        return s32Error;
6275
6276}
6277
6278
6279/**
6280 *  @brief              hif_get_cfg
6281 *  @details    gets configuration wids values
6282 *  @param[in,out] handle to the wifi driver,
6283 *                              WID value
6284 *  @param[in]  WID,
6285 *  @return             Error code indicating success/failure
6286 *  @note
6287 *  @author             zsalah
6288 *
6289 *  @date               8 March 2012
6290 *  @version            1.0
6291 */
6292s32 hif_get_cfg(tstrWILC_WFIDrv *hWFIDrv, u16 u16WID, u16 *pu16WID_Value)
6293{
6294        s32 s32Error = WILC_SUCCESS;
6295        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6296
6297        down(&(pstrWFIDrv->gtOsCfgValuesSem));
6298
6299        if (pstrWFIDrv == NULL) {
6300                PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
6301                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
6302        }
6303        PRINT_D(HOSTINF_DBG, "Getting configuration parameters\n");
6304        switch (u16WID) {
6305
6306        case WID_BSS_TYPE:
6307                *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.bss_type;
6308                break;
6309
6310        case WID_AUTH_TYPE:
6311                *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.auth_type;
6312                break;
6313
6314        case WID_AUTH_TIMEOUT:
6315                *pu16WID_Value = pstrWFIDrv->strCfgValues.auth_timeout;
6316                break;
6317
6318        case WID_POWER_MANAGEMENT:
6319                *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.power_mgmt_mode;
6320                break;
6321
6322        case WID_SHORT_RETRY_LIMIT:
6323                *pu16WID_Value =       pstrWFIDrv->strCfgValues.short_retry_limit;
6324                break;
6325
6326        case WID_LONG_RETRY_LIMIT:
6327                *pu16WID_Value = pstrWFIDrv->strCfgValues.long_retry_limit;
6328                break;
6329
6330        case WID_FRAG_THRESHOLD:
6331                *pu16WID_Value = pstrWFIDrv->strCfgValues.frag_threshold;
6332                break;
6333
6334        case WID_RTS_THRESHOLD:
6335                *pu16WID_Value = pstrWFIDrv->strCfgValues.rts_threshold;
6336                break;
6337
6338        case WID_PREAMBLE:
6339                *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.preamble_type;
6340                break;
6341
6342        case WID_SHORT_SLOT_ALLOWED:
6343                *pu16WID_Value = (u16) pstrWFIDrv->strCfgValues.short_slot_allowed;
6344                break;
6345
6346        case WID_11N_TXOP_PROT_DISABLE:
6347                *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.txop_prot_disabled;
6348                break;
6349
6350        case WID_BEACON_INTERVAL:
6351                *pu16WID_Value = pstrWFIDrv->strCfgValues.beacon_interval;
6352                break;
6353
6354        case WID_DTIM_PERIOD:
6355                *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.dtim_period;
6356                break;
6357
6358        case WID_SITE_SURVEY:
6359                *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.site_survey_enabled;
6360                break;
6361
6362        case WID_SITE_SURVEY_SCAN_TIME:
6363                *pu16WID_Value = pstrWFIDrv->strCfgValues.site_survey_scan_time;
6364                break;
6365
6366        case WID_ACTIVE_SCAN_TIME:
6367                *pu16WID_Value = pstrWFIDrv->strCfgValues.active_scan_time;
6368                break;
6369
6370        case WID_PASSIVE_SCAN_TIME:
6371                *pu16WID_Value = pstrWFIDrv->strCfgValues.passive_scan_time;
6372                break;
6373
6374        case WID_CURRENT_TX_RATE:
6375                *pu16WID_Value = pstrWFIDrv->strCfgValues.curr_tx_rate;
6376                break;
6377
6378        default:
6379                break;
6380        }
6381
6382        up(&(pstrWFIDrv->gtOsCfgValuesSem));
6383
6384        WILC_CATCH(s32Error)
6385        {
6386        }
6387        return s32Error;
6388
6389}
6390
6391/*****************************************************************************/
6392/*                                                      Notification Functions                                                   */
6393/*****************************************************************************/
6394/**
6395 *  @brief              notifies host with join and leave requests
6396 *  @details    This function prepares an Information frame having the
6397 *                              information about a joining/leaving station.
6398 *  @param[in,out] handle to the wifi driver,
6399 *  @param[in]  6 byte Sta Adress
6400 *                              Join or leave flag:
6401 *                              Join = 1,
6402 *                              Leave =0
6403 *  @return             Error code indicating success/failure
6404 *  @note
6405 *  @author             zsalah
6406 *  @date               8 March 2012
6407 *  @version            1.0
6408 */
6409void host_int_send_join_leave_info_to_host
6410        (u16 assocId, u8 *stationAddr, bool joining)
6411{
6412}
6413/**
6414 *  @brief              notifies host with stations found in scan
6415 *  @details    sends the beacon/probe response from scan
6416 *  @param[in,out] handle to the wifi driver,
6417 *  @param[in]  Sta Address,
6418 *                              Frame length,
6419 *                              Rssi of the Station found
6420 *  @return             Error code indicating success/failure
6421 *  @note
6422 *  @author             zsalah
6423 *  @date               8 March 2012
6424 *  @version            1.0
6425 */
6426
6427static void GetPeriodicRSSI(unsigned long arg)
6428{
6429        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)arg;
6430
6431        if (pstrWFIDrv == NULL) {
6432                PRINT_ER("Driver handler is NULL\n");
6433                return;
6434        }
6435
6436        if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) {
6437                s32 s32Error = WILC_SUCCESS;
6438                tstrHostIFmsg strHostIFmsg;
6439
6440                /* prepare the Get RSSI Message */
6441                memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6442
6443                strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_RSSI;
6444                strHostIFmsg.drvHandler = pstrWFIDrv;
6445
6446                /* send the message */
6447                s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
6448                if (s32Error) {
6449                        PRINT_ER("Failed to send get host channel param's message queue ");
6450                        return;
6451                }
6452        }
6453        g_hPeriodicRSSI.data = (unsigned long)pstrWFIDrv;
6454        mod_timer(&g_hPeriodicRSSI, jiffies + msecs_to_jiffies(5000));
6455}
6456
6457
6458void host_int_send_network_info_to_host
6459        (u8 *macStartAddress, u16 u16RxFrameLen, s8 s8Rssi)
6460{
6461}
6462/**
6463 *  @brief              host_int_init
6464 *  @details    host interface initialization function
6465 *  @param[in,out] handle to the wifi driver,
6466 *  @note
6467 *  @author             zsalah
6468 *  @date               8 March 2012
6469 *  @version            1.0
6470 */
6471static u32 u32Intialized;
6472static u32 msgQ_created;
6473static u32 clients_count;
6474
6475s32 host_int_init(tstrWILC_WFIDrv **phWFIDrv)
6476{
6477        s32 s32Error = WILC_SUCCESS;
6478        tstrWILC_WFIDrv *pstrWFIDrv;
6479
6480        /*if(u32Intialized == 1)
6481         * {
6482         *      PRINT_D(HOSTINF_DBG,"Host interface is previously initialized\n");
6483         * *phWFIDrv = (WILC_WFIDrvHandle)gWFiDrvHandle; //Will be adjusted later for P2P
6484         *      return 0;
6485         * }    */
6486        PRINT_D(HOSTINF_DBG, "Initializing host interface for client %d\n", clients_count + 1);
6487
6488        gbScanWhileConnected = false;
6489
6490        sema_init(&hWaitResponse, 0);
6491
6492
6493
6494        /*Allocate host interface private structure*/
6495        pstrWFIDrv  = WILC_MALLOC(sizeof(tstrWILC_WFIDrv));
6496        if (pstrWFIDrv == NULL) {
6497                /* WILC_ERRORREPORT(s32Error,WILC_NO_MEM); */
6498                s32Error = WILC_NO_MEM;
6499                PRINT_ER("Failed to allocate memory\n");
6500                goto _fail_timer_2;
6501        }
6502        memset(pstrWFIDrv, 0, sizeof(tstrWILC_WFIDrv));
6503        /*return driver handle to user*/
6504        *phWFIDrv = pstrWFIDrv;
6505        /*save into globl handle*/
6506
6507        #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
6508
6509        g_obtainingIP = false;
6510        #endif
6511
6512        PRINT_D(HOSTINF_DBG, "Global handle pointer value=%p\n", pstrWFIDrv);
6513        /* /////////////////////////////////////// */
6514        if (clients_count == 0) {
6515                sema_init(&hSemHostIFthrdEnd, 0);
6516                sema_init(&hSemDeinitDrvHandle, 0);
6517                /*BugID_5348*/
6518                sema_init(&hSemHostIntDeinit, 1);
6519        }
6520
6521        sema_init(&(pstrWFIDrv->hSemTestKeyBlock), 0);
6522        sema_init(&(pstrWFIDrv->hSemTestDisconnectBlock), 0);
6523        sema_init(&(pstrWFIDrv->hSemGetRSSI), 0);
6524        sema_init(&(pstrWFIDrv->hSemGetLINKSPEED), 0);
6525        sema_init(&(pstrWFIDrv->hSemGetCHNL), 0);
6526        sema_init(&(pstrWFIDrv->hSemInactiveTime), 0);
6527
6528        /* /////////////////////////////////////// */
6529
6530
6531
6532        PRINT_D(HOSTINF_DBG, "INIT: CLIENT COUNT %d\n", clients_count);
6533
6534        if (clients_count == 0) {
6535                s32Error = WILC_MsgQueueCreate(&gMsgQHostIF);
6536
6537                if (s32Error < 0) {
6538                        PRINT_ER("Failed to creat MQ\n");
6539                        goto _fail_;
6540                }
6541                msgQ_created = 1;
6542                HostIFthreadHandler = kthread_run(hostIFthread, NULL, "WILC_kthread");
6543                if (IS_ERR(HostIFthreadHandler)) {
6544                        PRINT_ER("Failed to creat Thread\n");
6545                        s32Error = WILC_FAIL;
6546                        goto _fail_mq_;
6547                }
6548                setup_timer(&g_hPeriodicRSSI, GetPeriodicRSSI,
6549                            (unsigned long)pstrWFIDrv);
6550                mod_timer(&g_hPeriodicRSSI, jiffies + msecs_to_jiffies(5000));
6551        }
6552
6553
6554        setup_timer(&pstrWFIDrv->hScanTimer, TimerCB_Scan, 0);
6555
6556        setup_timer(&pstrWFIDrv->hConnectTimer, TimerCB_Connect, 0);
6557
6558        #ifdef WILC_P2P
6559        /*Remain on channel timer*/
6560        setup_timer(&pstrWFIDrv->hRemainOnChannel, ListenTimerCB, 0);
6561        #endif
6562
6563        sema_init(&(pstrWFIDrv->gtOsCfgValuesSem), 1);
6564        down(&(pstrWFIDrv->gtOsCfgValuesSem));
6565
6566        pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
6567        /* gWFiDrvHandle->bPendingConnRequest = false; */
6568
6569        /*Initialize CFG WIDS Defualt Values*/
6570
6571        pstrWFIDrv->strCfgValues.site_survey_enabled = SITE_SURVEY_OFF;
6572        pstrWFIDrv->strCfgValues.scan_source = DEFAULT_SCAN;
6573        pstrWFIDrv->strCfgValues.active_scan_time = ACTIVE_SCAN_TIME;
6574        pstrWFIDrv->strCfgValues.passive_scan_time = PASSIVE_SCAN_TIME;
6575        pstrWFIDrv->strCfgValues.curr_tx_rate = AUTORATE;
6576
6577
6578        #ifdef WILC_P2P
6579
6580        pstrWFIDrv->u64P2p_MgmtTimeout = 0;
6581
6582        #endif
6583
6584        PRINT_INFO(HOSTINF_DBG, "Initialization values, Site survey value: %d\n Scan source: %d\n Active scan time: %d\n Passive scan time: %d\nCurrent tx Rate = %d\n",
6585
6586                   pstrWFIDrv->strCfgValues.site_survey_enabled, pstrWFIDrv->strCfgValues.scan_source,
6587                   pstrWFIDrv->strCfgValues.active_scan_time, pstrWFIDrv->strCfgValues.passive_scan_time,
6588                   pstrWFIDrv->strCfgValues.curr_tx_rate);
6589
6590
6591        up(&(pstrWFIDrv->gtOsCfgValuesSem));
6592
6593        /*TODO Code to setup simulation to be removed later*/
6594        /*Intialize configurator module*/
6595        s32Error = CoreConfiguratorInit();
6596        if (s32Error < 0) {
6597                PRINT_ER("Failed to initialize core configurator\n");
6598                goto _fail_mem_;
6599        }
6600
6601        u32Intialized = 1;
6602        clients_count++; /* increase number of created entities */
6603
6604        return s32Error;
6605
6606
6607_fail_mem_:
6608        if (pstrWFIDrv != NULL)
6609                kfree(pstrWFIDrv);
6610#ifdef WILC_P2P
6611        del_timer_sync(&pstrWFIDrv->hRemainOnChannel);
6612#endif
6613_fail_timer_2:
6614        up(&(pstrWFIDrv->gtOsCfgValuesSem));
6615        del_timer_sync(&pstrWFIDrv->hConnectTimer);
6616        del_timer_sync(&pstrWFIDrv->hScanTimer);
6617        kthread_stop(HostIFthreadHandler);
6618_fail_mq_:
6619        WILC_MsgQueueDestroy(&gMsgQHostIF);
6620_fail_:
6621        return s32Error;
6622
6623
6624}
6625/**
6626 *  @brief              host_int_deinit
6627 *  @details    host interface initialization function
6628 *  @param[in,out] handle to the wifi driver,
6629 *  @note
6630 *  @author             zsalah
6631 *  @date               8 March 2012
6632 *  @version            1.0
6633 */
6634
6635s32 host_int_deinit(tstrWILC_WFIDrv *hWFIDrv)
6636{
6637        s32 s32Error = WILC_SUCCESS;
6638        tstrHostIFmsg strHostIFmsg;
6639
6640
6641        /*obtain driver handle*/
6642        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6643        /*if(u32Intialized == 0)
6644         * {
6645         *      PRINT_ER("Host Interface is not initialized\n");
6646         *      return 0;
6647         * }*/
6648
6649        /*BugID_5348*/
6650
6651        if (pstrWFIDrv == NULL) {
6652                PRINT_ER("pstrWFIDrv = NULL\n");
6653                return 0;
6654        }
6655
6656        down(&hSemHostIntDeinit);
6657
6658        terminated_handle = pstrWFIDrv;
6659        PRINT_D(HOSTINF_DBG, "De-initializing host interface for client %d\n", clients_count);
6660
6661        /*BugID_5348*/
6662        /*Destroy all timers before acquiring hSemDeinitDrvHandle*/
6663        /*to guarantee handling all messages befor proceeding*/
6664        if (del_timer_sync(&pstrWFIDrv->hScanTimer)) {
6665                PRINT_D(HOSTINF_DBG, ">> Scan timer is active\n");
6666                /* msleep(HOST_IF_SCAN_TIMEOUT+1000); */
6667        }
6668
6669        if (del_timer_sync(&pstrWFIDrv->hConnectTimer)) {
6670                PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
6671                /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6672        }
6673
6674
6675        if (del_timer_sync(&g_hPeriodicRSSI)) {
6676                PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
6677                /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6678        }
6679
6680        #ifdef WILC_P2P
6681        /*Destroy Remain-onchannel Timer*/
6682        del_timer_sync(&pstrWFIDrv->hRemainOnChannel);
6683        #endif
6684
6685        host_int_set_wfi_drv_handler(NULL);
6686        down(&hSemDeinitDrvHandle);
6687
6688
6689        /*Calling the CFG80211 scan done function with the abort flag set to true*/
6690        if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
6691                pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
6692                                                                pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
6693
6694                pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
6695        }
6696        /*deinit configurator and simulator*/
6697        CoreConfiguratorDeInit();
6698
6699        pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
6700
6701        gbScanWhileConnected = false;
6702
6703        memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6704
6705        if (clients_count == 1) {
6706                if (del_timer_sync(&g_hPeriodicRSSI)) {
6707                        PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
6708                        /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6709                }
6710                strHostIFmsg.u16MsgId = HOST_IF_MSG_EXIT;
6711                strHostIFmsg.drvHandler = hWFIDrv;
6712
6713
6714                s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
6715                if (s32Error != WILC_SUCCESS)
6716                        PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", s32Error);
6717
6718                down(&hSemHostIFthrdEnd);
6719
6720                WILC_MsgQueueDestroy(&gMsgQHostIF);
6721                msgQ_created = 0;
6722        }
6723
6724        down(&(pstrWFIDrv->gtOsCfgValuesSem));
6725
6726        /*Setting the gloabl driver handler with NULL*/
6727        u32Intialized = 0;
6728        /* gWFiDrvHandle = NULL; */
6729        if (pstrWFIDrv != NULL) {
6730                kfree(pstrWFIDrv);
6731                /* pstrWFIDrv=NULL; */
6732
6733        }
6734
6735        clients_count--; /* Decrease number of created entities */
6736        terminated_handle = NULL;
6737        up(&hSemHostIntDeinit);
6738        return s32Error;
6739}
6740
6741
6742/**
6743 *  @brief              NetworkInfoReceived
6744 *  @details    function to to be called when network info packet is received
6745 *  @param[in]  pu8Buffer the received packet
6746 *  @param[in]   u32Length  length of the received packet
6747 *  @return             none
6748 *  @note
6749 *  @author
6750 *  @date               1 Mar 2012
6751 *  @version            1.0
6752 */
6753void NetworkInfoReceived(u8 *pu8Buffer, u32 u32Length)
6754{
6755        s32 s32Error = WILC_SUCCESS;
6756        tstrHostIFmsg strHostIFmsg;
6757        u32 drvHandler;
6758        tstrWILC_WFIDrv *pstrWFIDrv = NULL;
6759
6760        drvHandler = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
6761        pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
6762
6763
6764
6765
6766        if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle)      {
6767                PRINT_ER("NetworkInfo received but driver not init[%p]\n", pstrWFIDrv);
6768                return;
6769        }
6770
6771        /* prepare the Asynchronous Network Info message */
6772        memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6773
6774        strHostIFmsg.u16MsgId = HOST_IF_MSG_RCVD_NTWRK_INFO;
6775        strHostIFmsg.drvHandler = pstrWFIDrv;
6776
6777        strHostIFmsg.uniHostIFmsgBody.strRcvdNetworkInfo.u32Length = u32Length;
6778        strHostIFmsg.uniHostIFmsgBody.strRcvdNetworkInfo.pu8Buffer = WILC_MALLOC(u32Length); /* will be deallocated by the receiving thread */
6779        memcpy(strHostIFmsg.uniHostIFmsgBody.strRcvdNetworkInfo.pu8Buffer,
6780                    pu8Buffer, u32Length);
6781
6782        /* send the message */
6783        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
6784        if (s32Error)
6785                PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", s32Error);
6786}
6787
6788/**
6789 *  @brief              GnrlAsyncInfoReceived
6790 *  @details    function to be called when general Asynchronous info packet is received
6791 *  @param[in]  pu8Buffer the received packet
6792 *  @param[in]   u32Length  length of the received packet
6793 *  @return             none
6794 *  @note
6795 *  @author
6796 *  @date               15 Mar 2012
6797 *  @version            1.0
6798 */
6799void GnrlAsyncInfoReceived(u8 *pu8Buffer, u32 u32Length)
6800{
6801        s32 s32Error = WILC_SUCCESS;
6802        tstrHostIFmsg strHostIFmsg;
6803        u32 drvHandler;
6804        tstrWILC_WFIDrv *pstrWFIDrv = NULL;
6805
6806        /*BugID_5348*/
6807        down(&hSemHostIntDeinit);
6808
6809        drvHandler = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
6810        pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
6811        PRINT_D(HOSTINF_DBG, "General asynchronous info packet received\n");
6812
6813
6814        if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle) {
6815                PRINT_D(HOSTINF_DBG, "Wifi driver handler is equal to NULL\n");
6816                /*BugID_5348*/
6817                up(&hSemHostIntDeinit);
6818                return;
6819        }
6820
6821        if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult == NULL) {
6822                /* received mac status is not needed when there is no current Connect Request */
6823                PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n");
6824                /*BugID_5348*/
6825                up(&hSemHostIntDeinit);
6826                return;
6827        }
6828
6829        /* prepare the General Asynchronous Info message */
6830        memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6831
6832
6833        strHostIFmsg.u16MsgId = HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO;
6834        strHostIFmsg.drvHandler = pstrWFIDrv;
6835
6836
6837        strHostIFmsg.uniHostIFmsgBody.strRcvdGnrlAsyncInfo.u32Length = u32Length;
6838        strHostIFmsg.uniHostIFmsgBody.strRcvdGnrlAsyncInfo.pu8Buffer = WILC_MALLOC(u32Length); /* will be deallocated by the receiving thread */
6839        memcpy(strHostIFmsg.uniHostIFmsgBody.strRcvdGnrlAsyncInfo.pu8Buffer,
6840                    pu8Buffer, u32Length);
6841
6842        /* send the message */
6843        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
6844        if (s32Error)
6845                PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", s32Error);
6846
6847        /*BugID_5348*/
6848        up(&hSemHostIntDeinit);
6849}
6850
6851/**
6852 *  @brief host_int_ScanCompleteReceived
6853 *  @details        Setting scan complete received notifcation in message queue
6854 *  @param[in]     u8* pu8Buffer, u32 u32Length
6855 *  @return         Error code.
6856 *  @author
6857 *  @date
6858 *  @version    1.0
6859 */
6860void host_int_ScanCompleteReceived(u8 *pu8Buffer, u32 u32Length)
6861{
6862        s32 s32Error = WILC_SUCCESS;
6863        tstrHostIFmsg strHostIFmsg;
6864        u32 drvHandler;
6865        tstrWILC_WFIDrv *pstrWFIDrv = NULL;
6866
6867        drvHandler = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
6868        pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
6869
6870
6871        PRINT_D(GENERIC_DBG, "Scan notification received %p\n", pstrWFIDrv);
6872
6873        if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle)
6874                return;
6875
6876        /*if there is an ongoing scan request*/
6877        if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
6878                /* prepare theScan Done message */
6879                memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6880
6881                strHostIFmsg.u16MsgId = HOST_IF_MSG_RCVD_SCAN_COMPLETE;
6882                strHostIFmsg.drvHandler = pstrWFIDrv;
6883
6884
6885                /* will be deallocated by the receiving thread */
6886                /*no need to send message body*/
6887
6888                /*strHostIFmsg.uniHostIFmsgBody.strScanComplete.u32Length = u32Length;
6889                 * strHostIFmsg.uniHostIFmsgBody.strScanComplete.pu8Buffer  = (u8*)WILC_MALLOC(u32Length);
6890                 * memcpy(strHostIFmsg.uniHostIFmsgBody.strScanComplete.pu8Buffer,
6891                 *                        pu8Buffer, u32Length); */
6892
6893                /* send the message */
6894                s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
6895                if (s32Error)
6896                        PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", s32Error);
6897        }
6898
6899
6900        return;
6901
6902}
6903
6904#ifdef WILC_P2P
6905/**
6906 *  @brief              host_int_remain_on_channel
6907 *  @details
6908 *  @param[in]          Handle to wifi driver
6909 *                              Duration to remain on channel
6910 *                              Channel to remain on
6911 *                              Pointer to fn to be called on receive frames in listen state
6912 *                              Pointer to remain-on-channel expired fn
6913 *                              Priv
6914 *  @return             Error code.
6915 *  @author
6916 *  @date
6917 *  @version            1.0
6918 */
6919s32 host_int_remain_on_channel(tstrWILC_WFIDrv *hWFIDrv, u32 u32SessionID, u32 u32duration, u16 chan, tWILCpfRemainOnChanExpired RemainOnChanExpired, tWILCpfRemainOnChanReady RemainOnChanReady, void *pvUserArg)
6920{
6921        s32 s32Error = WILC_SUCCESS;
6922        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6923        tstrHostIFmsg strHostIFmsg;
6924
6925        if (pstrWFIDrv == NULL)
6926                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
6927
6928        /* prepare the remainonchan Message */
6929        memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6930
6931        /* prepare the WiphyParams Message */
6932        strHostIFmsg.u16MsgId = HOST_IF_MSG_REMAIN_ON_CHAN;
6933        strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u16Channel = chan;
6934        strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.pRemainOnChanExpired = RemainOnChanExpired;
6935        strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.pRemainOnChanReady = RemainOnChanReady;
6936        strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.pVoid = pvUserArg;
6937        strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u32duration = u32duration;
6938        strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u32ListenSessionID = u32SessionID;
6939        strHostIFmsg.drvHandler = hWFIDrv;
6940
6941        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
6942        if (s32Error)
6943                WILC_ERRORREPORT(s32Error, s32Error);
6944        WILC_CATCH(s32Error)
6945        {
6946
6947        }
6948
6949        return s32Error;
6950}
6951
6952/**
6953 *  @brief              host_int_ListenStateExpired
6954 *  @details
6955 *  @param[in]          Handle to wifi driver
6956 *                              Duration to remain on channel
6957 *                              Channel to remain on
6958 *                              Pointer to fn to be called on receive frames in listen state
6959 *                              Pointer to remain-on-channel expired fn
6960 *                              Priv
6961 *  @return             Error code.
6962 *  @author
6963 *  @date
6964 *  @version            1.0
6965 */
6966s32 host_int_ListenStateExpired(tstrWILC_WFIDrv *hWFIDrv, u32 u32SessionID)
6967{
6968        s32 s32Error = WILC_SUCCESS;
6969        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6970        tstrHostIFmsg strHostIFmsg;
6971
6972        if (pstrWFIDrv == NULL)
6973                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
6974
6975        /*Stopping remain-on-channel timer*/
6976        del_timer(&pstrWFIDrv->hRemainOnChannel);
6977
6978        /* prepare the timer fire Message */
6979        memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6980        strHostIFmsg.u16MsgId = HOST_IF_MSG_LISTEN_TIMER_FIRED;
6981        strHostIFmsg.drvHandler = hWFIDrv;
6982        strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u32ListenSessionID = u32SessionID;
6983
6984        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
6985        if (s32Error)
6986                WILC_ERRORREPORT(s32Error, s32Error);
6987        WILC_CATCH(s32Error)
6988        {
6989
6990        }
6991        return s32Error;
6992}
6993
6994/**
6995 *  @brief              host_int_frame_register
6996 *  @details
6997 *  @param[in]          Handle to wifi driver
6998 *  @return             Error code.
6999 *  @author
7000 *  @date
7001 *  @version            1.0*/
7002s32 host_int_frame_register(tstrWILC_WFIDrv *hWFIDrv, u16 u16FrameType, bool bReg)
7003{
7004        s32 s32Error = WILC_SUCCESS;
7005        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7006        tstrHostIFmsg strHostIFmsg;
7007
7008        if (pstrWFIDrv == NULL)
7009                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7010
7011        memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7012
7013        /* prepare the WiphyParams Message */
7014        strHostIFmsg.u16MsgId = HOST_IF_MSG_REGISTER_FRAME;
7015        switch (u16FrameType) {
7016        case ACTION:
7017                PRINT_D(HOSTINF_DBG, "ACTION\n");
7018                strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame.u8Regid = ACTION_FRM_IDX;
7019                break;
7020
7021        case PROBE_REQ:
7022                PRINT_D(HOSTINF_DBG, "PROBE REQ\n");
7023                strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame.u8Regid = PROBE_REQ_IDX;
7024                break;
7025
7026        default:
7027                PRINT_D(HOSTINF_DBG, "Not valid frame type\n");
7028                break;
7029        }
7030        strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame.u16FrameType = u16FrameType;
7031        strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame.bReg = bReg;
7032        strHostIFmsg.drvHandler = hWFIDrv;
7033
7034        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
7035        if (s32Error)
7036                WILC_ERRORREPORT(s32Error, s32Error);
7037        WILC_CATCH(s32Error)
7038        {
7039
7040        }
7041
7042        return s32Error;
7043
7044
7045}
7046#endif
7047
7048#ifdef WILC_AP_EXTERNAL_MLME
7049/**
7050 *  @brief host_int_add_beacon
7051 *  @details       Setting add beacon params in message queue
7052 *  @param[in]    WILC_WFIDrvHandle hWFIDrv, u32 u32Interval,
7053 *                         u32 u32DTIMPeriod,u32 u32HeadLen, u8* pu8Head,
7054 *                         u32 u32TailLen, u8* pu8Tail
7055 *  @return         Error code.
7056 *  @author
7057 *  @date
7058 *  @version    1.0
7059 */
7060s32 host_int_add_beacon(tstrWILC_WFIDrv *hWFIDrv, u32 u32Interval,
7061                                u32 u32DTIMPeriod,
7062                                u32 u32HeadLen, u8 *pu8Head,
7063                                u32 u32TailLen, u8 *pu8Tail)
7064{
7065        s32 s32Error = WILC_SUCCESS;
7066        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7067        tstrHostIFmsg strHostIFmsg;
7068        tstrHostIFSetBeacon *pstrSetBeaconParam = &strHostIFmsg.uniHostIFmsgBody.strHostIFSetBeacon;
7069
7070        if (pstrWFIDrv == NULL)
7071                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7072
7073        memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7074
7075        PRINT_D(HOSTINF_DBG, "Setting adding beacon message queue params\n");
7076
7077
7078        /* prepare the WiphyParams Message */
7079        strHostIFmsg.u16MsgId = HOST_IF_MSG_ADD_BEACON;
7080        strHostIFmsg.drvHandler = hWFIDrv;
7081        pstrSetBeaconParam->u32Interval = u32Interval;
7082        pstrSetBeaconParam->u32DTIMPeriod = u32DTIMPeriod;
7083        pstrSetBeaconParam->u32HeadLen = u32HeadLen;
7084        pstrSetBeaconParam->pu8Head = WILC_MALLOC(u32HeadLen);
7085        if (pstrSetBeaconParam->pu8Head == NULL)
7086                WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
7087        memcpy(pstrSetBeaconParam->pu8Head, pu8Head, u32HeadLen);
7088        pstrSetBeaconParam->u32TailLen = u32TailLen;
7089
7090        /* Bug 4599 : if tail length = 0 skip allocating & copying */
7091        if (u32TailLen > 0) {
7092                pstrSetBeaconParam->pu8Tail = WILC_MALLOC(u32TailLen);
7093                if (pstrSetBeaconParam->pu8Tail == NULL)
7094                        WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
7095                memcpy(pstrSetBeaconParam->pu8Tail, pu8Tail, u32TailLen);
7096        } else {
7097                pstrSetBeaconParam->pu8Tail = NULL;
7098        }
7099
7100        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
7101        if (s32Error)
7102                WILC_ERRORREPORT(s32Error, s32Error);
7103
7104        WILC_CATCH(s32Error)
7105        {
7106                if (pstrSetBeaconParam->pu8Head != NULL)
7107                        kfree(pstrSetBeaconParam->pu8Head);
7108
7109                if (pstrSetBeaconParam->pu8Tail != NULL)
7110                        kfree(pstrSetBeaconParam->pu8Tail);
7111        }
7112
7113        return s32Error;
7114
7115}
7116
7117
7118/**
7119 *  @brief host_int_del_beacon
7120 *  @details       Setting add beacon params in message queue
7121 *  @param[in]    WILC_WFIDrvHandle hWFIDrv
7122 *  @return         Error code.
7123 *  @author
7124 *  @date
7125 *  @version    1.0
7126 */
7127s32 host_int_del_beacon(tstrWILC_WFIDrv *hWFIDrv)
7128{
7129        s32 s32Error = WILC_SUCCESS;
7130        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7131        tstrHostIFmsg strHostIFmsg;
7132
7133        if (pstrWFIDrv == NULL)
7134                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7135
7136        /* prepare the WiphyParams Message */
7137        strHostIFmsg.u16MsgId = HOST_IF_MSG_DEL_BEACON;
7138        strHostIFmsg.drvHandler = hWFIDrv;
7139        PRINT_D(HOSTINF_DBG, "Setting deleting beacon message queue params\n");
7140
7141        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
7142        WILC_ERRORCHECK(s32Error);
7143
7144        WILC_CATCH(s32Error)
7145        {
7146        }
7147        return s32Error;
7148}
7149
7150
7151/**
7152 *  @brief host_int_add_station
7153 *  @details       Setting add station params in message queue
7154 *  @param[in]    WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam* pstrStaParams
7155 *  @return         Error code.
7156 *  @author
7157 *  @date
7158 *  @version    1.0
7159 */
7160s32 host_int_add_station(tstrWILC_WFIDrv *hWFIDrv, tstrWILC_AddStaParam *pstrStaParams)
7161{
7162        s32 s32Error = WILC_SUCCESS;
7163        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7164        tstrHostIFmsg strHostIFmsg;
7165        tstrWILC_AddStaParam *pstrAddStationMsg = &strHostIFmsg.uniHostIFmsgBody.strAddStaParam;
7166
7167
7168        if (pstrWFIDrv == NULL)
7169                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7170
7171        memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7172
7173        PRINT_D(HOSTINF_DBG, "Setting adding station message queue params\n");
7174
7175
7176        /* prepare the WiphyParams Message */
7177        strHostIFmsg.u16MsgId = HOST_IF_MSG_ADD_STATION;
7178        strHostIFmsg.drvHandler = hWFIDrv;
7179
7180        memcpy(pstrAddStationMsg, pstrStaParams, sizeof(tstrWILC_AddStaParam));
7181        if (pstrAddStationMsg->u8NumRates > 0) {
7182                u8 *rates = WILC_MALLOC(pstrAddStationMsg->u8NumRates);
7183
7184                WILC_NULLCHECK(s32Error, rates);
7185
7186                memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
7187                pstrAddStationMsg->pu8Rates = rates;
7188        }
7189
7190
7191        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
7192        if (s32Error)
7193                WILC_ERRORREPORT(s32Error, s32Error);
7194
7195        WILC_CATCH(s32Error)
7196        {
7197        }
7198        return s32Error;
7199}
7200
7201/**
7202 *  @brief host_int_del_station
7203 *  @details       Setting delete station params in message queue
7204 *  @param[in]    WILC_WFIDrvHandle hWFIDrv, u8* pu8MacAddr
7205 *  @return         Error code.
7206 *  @author
7207 *  @date
7208 *  @version    1.0
7209 */
7210s32 host_int_del_station(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8MacAddr)
7211{
7212        s32 s32Error = WILC_SUCCESS;
7213        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7214        tstrHostIFmsg strHostIFmsg;
7215        tstrHostIFDelSta *pstrDelStationMsg = &strHostIFmsg.uniHostIFmsgBody.strDelStaParam;
7216
7217        if (pstrWFIDrv == NULL)
7218                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7219
7220        memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7221
7222        PRINT_D(HOSTINF_DBG, "Setting deleting station message queue params\n");
7223
7224
7225
7226        /* prepare the WiphyParams Message */
7227        strHostIFmsg.u16MsgId = HOST_IF_MSG_DEL_STATION;
7228        strHostIFmsg.drvHandler = hWFIDrv;
7229
7230        /*BugID_4795: Handling situation of deleting all stations*/
7231        if (pu8MacAddr == NULL)
7232                memset(pstrDelStationMsg->au8MacAddr, 255, ETH_ALEN);
7233        else
7234                memcpy(pstrDelStationMsg->au8MacAddr, pu8MacAddr, ETH_ALEN);
7235
7236        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
7237        if (s32Error)
7238                WILC_ERRORREPORT(s32Error, s32Error);
7239
7240        WILC_CATCH(s32Error)
7241        {
7242        }
7243        return s32Error;
7244}
7245/**
7246 *  @brief      host_int_del_allstation
7247 *  @details    Setting del station params in message queue
7248 *  @param[in]  WILC_WFIDrvHandle hWFIDrv, u8 pu8MacAddr[][ETH_ALEN]s
7249 *  @return        Error code.
7250 *  @author
7251 *  @date
7252 *  @version    1.0
7253 */
7254s32 host_int_del_allstation(tstrWILC_WFIDrv *hWFIDrv, u8 pu8MacAddr[][ETH_ALEN])
7255{
7256        s32 s32Error = WILC_SUCCESS;
7257        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7258        tstrHostIFmsg strHostIFmsg;
7259        tstrHostIFDelAllSta *pstrDelAllStationMsg = &strHostIFmsg.uniHostIFmsgBody.strHostIFDelAllSta;
7260        u8 au8Zero_Buff[ETH_ALEN] = {0};
7261        u32 i;
7262        u8 u8AssocNumb = 0;
7263
7264
7265        if (pstrWFIDrv == NULL)
7266                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7267
7268        memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7269
7270        PRINT_D(HOSTINF_DBG, "Setting deauthenticating station message queue params\n");
7271
7272        /* prepare the WiphyParams Message */
7273        strHostIFmsg.u16MsgId = HOST_IF_MSG_DEL_ALL_STA;
7274        strHostIFmsg.drvHandler = hWFIDrv;
7275
7276        /* Handling situation of deauthenticing all associated stations*/
7277        for (i = 0; i < MAX_NUM_STA; i++) {
7278                if (memcmp(pu8MacAddr[i], au8Zero_Buff, ETH_ALEN)) {
7279                        memcpy(pstrDelAllStationMsg->au8Sta_DelAllSta[i], pu8MacAddr[i], ETH_ALEN);
7280                        PRINT_D(CFG80211_DBG, "BSSID = %x%x%x%x%x%x\n", pstrDelAllStationMsg->au8Sta_DelAllSta[i][0], pstrDelAllStationMsg->au8Sta_DelAllSta[i][1], pstrDelAllStationMsg->au8Sta_DelAllSta[i][2], pstrDelAllStationMsg->au8Sta_DelAllSta[i][3], pstrDelAllStationMsg->au8Sta_DelAllSta[i][4],
7281                                pstrDelAllStationMsg->au8Sta_DelAllSta[i][5]);
7282                        u8AssocNumb++;
7283                }
7284        }
7285        if (!u8AssocNumb) {
7286                PRINT_D(CFG80211_DBG, "NO ASSOCIATED STAS\n");
7287                return s32Error;
7288        }
7289
7290        pstrDelAllStationMsg->u8Num_AssocSta = u8AssocNumb;
7291        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
7292
7293
7294        if (s32Error)
7295                WILC_ERRORREPORT(s32Error, s32Error);
7296
7297        WILC_CATCH(s32Error)
7298        {
7299
7300        }
7301        down(&hWaitResponse);
7302
7303        return s32Error;
7304
7305}
7306
7307/**
7308 *  @brief host_int_edit_station
7309 *  @details       Setting edit station params in message queue
7310 *  @param[in]    WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam* pstrStaParams
7311 *  @return         Error code.
7312 *  @author
7313 *  @date
7314 *  @version    1.0
7315 */
7316s32 host_int_edit_station(tstrWILC_WFIDrv *hWFIDrv, tstrWILC_AddStaParam *pstrStaParams)
7317{
7318        s32 s32Error = WILC_SUCCESS;
7319        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7320        tstrHostIFmsg strHostIFmsg;
7321        tstrWILC_AddStaParam *pstrAddStationMsg = &strHostIFmsg.uniHostIFmsgBody.strAddStaParam;
7322
7323        if (pstrWFIDrv == NULL)
7324                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7325
7326        PRINT_D(HOSTINF_DBG, "Setting editing station message queue params\n");
7327
7328        memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7329
7330
7331        /* prepare the WiphyParams Message */
7332        strHostIFmsg.u16MsgId = HOST_IF_MSG_EDIT_STATION;
7333        strHostIFmsg.drvHandler = hWFIDrv;
7334
7335        memcpy(pstrAddStationMsg, pstrStaParams, sizeof(tstrWILC_AddStaParam));
7336        if (pstrAddStationMsg->u8NumRates > 0) {
7337                u8 *rates = WILC_MALLOC(pstrAddStationMsg->u8NumRates);
7338
7339                WILC_NULLCHECK(s32Error, rates);
7340                memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
7341                pstrAddStationMsg->pu8Rates = rates;
7342        }
7343
7344        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
7345        if (s32Error)
7346                WILC_ERRORREPORT(s32Error, s32Error);
7347        WILC_CATCH(s32Error)
7348        {
7349        }
7350        return s32Error;
7351}
7352#endif /*WILC_AP_EXTERNAL_MLME*/
7353uint32_t wilc_get_chipid(uint8_t);
7354
7355s32 host_int_set_power_mgmt(tstrWILC_WFIDrv *hWFIDrv, bool bIsEnabled, u32 u32Timeout)
7356{
7357        s32 s32Error = WILC_SUCCESS;
7358        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7359        tstrHostIFmsg strHostIFmsg;
7360        tstrHostIfPowerMgmtParam *pstrPowerMgmtParam = &strHostIFmsg.uniHostIFmsgBody.strPowerMgmtparam;
7361
7362        PRINT_INFO(HOSTINF_DBG, "\n\n>> Setting PS to %d <<\n\n", bIsEnabled);
7363
7364        if (pstrWFIDrv == NULL)
7365                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7366
7367        PRINT_D(HOSTINF_DBG, "Setting Power management message queue params\n");
7368
7369        memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7370
7371
7372        /* prepare the WiphyParams Message */
7373        strHostIFmsg.u16MsgId = HOST_IF_MSG_POWER_MGMT;
7374        strHostIFmsg.drvHandler = hWFIDrv;
7375
7376        pstrPowerMgmtParam->bIsEnabled = bIsEnabled;
7377        pstrPowerMgmtParam->u32Timeout = u32Timeout;
7378
7379
7380        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
7381        if (s32Error)
7382                WILC_ERRORREPORT(s32Error, s32Error);
7383        WILC_CATCH(s32Error)
7384        {
7385        }
7386        return s32Error;
7387}
7388
7389s32 host_int_setup_multicast_filter(tstrWILC_WFIDrv *hWFIDrv, bool bIsEnabled, u32 u32count)
7390{
7391        s32 s32Error = WILC_SUCCESS;
7392
7393        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7394        tstrHostIFmsg strHostIFmsg;
7395        tstrHostIFSetMulti *pstrMulticastFilterParam = &strHostIFmsg.uniHostIFmsgBody.strHostIfSetMulti;
7396
7397
7398        if (pstrWFIDrv == NULL)
7399                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7400
7401        PRINT_D(HOSTINF_DBG, "Setting Multicast Filter params\n");
7402
7403        memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7404
7405
7406        /* prepare the WiphyParams Message */
7407        strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_MULTICAST_FILTER;
7408        strHostIFmsg.drvHandler = hWFIDrv;
7409
7410        pstrMulticastFilterParam->bIsEnabled = bIsEnabled;
7411        pstrMulticastFilterParam->u32count = u32count;
7412
7413        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
7414        if (s32Error)
7415                WILC_ERRORREPORT(s32Error, s32Error);
7416        WILC_CATCH(s32Error)
7417        {
7418        }
7419        return s32Error;
7420}
7421
7422
7423
7424/*Bug4218: Parsing Join Param*/
7425#ifdef WILC_PARSE_SCAN_IN_HOST
7426
7427/*Bug4218: Parsing Join Param*/
7428/**
7429 *  @brief              host_int_ParseJoinBssParam
7430 *  @details            Parse Needed Join Parameters and save it in a new JoinBssParam entry
7431 *  @param[in]          tstrNetworkInfo* ptstrNetworkInfo
7432 *  @return
7433 *  @author             zsalah
7434 *  @date
7435 *  @version            1.0**/
7436static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo)
7437{
7438        tstrJoinBssParam *pNewJoinBssParam = NULL;
7439        u8 *pu8IEs;
7440        u16 u16IEsLen;
7441        u16 index = 0;
7442        u8 suppRatesNo = 0;
7443        u8 extSuppRatesNo;
7444        u16 jumpOffset;
7445        u8 pcipherCount;
7446        u8 authCount;
7447        u8 pcipherTotalCount = 0;
7448        u8 authTotalCount = 0;
7449        u8 i, j;
7450
7451        pu8IEs = ptstrNetworkInfo->pu8IEs;
7452        u16IEsLen = ptstrNetworkInfo->u16IEsLen;
7453
7454        pNewJoinBssParam = WILC_MALLOC(sizeof(tstrJoinBssParam));
7455        if (pNewJoinBssParam != NULL) {
7456                memset(pNewJoinBssParam, 0, sizeof(tstrJoinBssParam));
7457                pNewJoinBssParam->dtim_period = ptstrNetworkInfo->u8DtimPeriod;
7458                pNewJoinBssParam->beacon_period = ptstrNetworkInfo->u16BeaconPeriod;
7459                pNewJoinBssParam->cap_info = ptstrNetworkInfo->u16CapInfo;
7460                memcpy(pNewJoinBssParam->au8bssid, ptstrNetworkInfo->au8bssid, 6);
7461                /*for(i=0; i<6;i++)
7462                 *      PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->au8bssid[i]);*/
7463                memcpy((u8 *)pNewJoinBssParam->ssid, ptstrNetworkInfo->au8ssid, ptstrNetworkInfo->u8SsidLen + 1);
7464                pNewJoinBssParam->ssidLen = ptstrNetworkInfo->u8SsidLen;
7465                memset(pNewJoinBssParam->rsn_pcip_policy, 0xFF, 3);
7466                memset(pNewJoinBssParam->rsn_auth_policy, 0xFF, 3);
7467                /*for(i=0; i<pNewJoinBssParam->ssidLen;i++)
7468                 *      PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->ssid[i]);*/
7469
7470                /* parse supported rates: */
7471                while (index < u16IEsLen) {
7472                        /* supportedRates IE */
7473                        if (pu8IEs[index] == SUPP_RATES_IE) {
7474                                /* PRINT_D(HOSTINF_DBG, "Supported Rates\n"); */
7475                                suppRatesNo = pu8IEs[index + 1];
7476                                pNewJoinBssParam->supp_rates[0] = suppRatesNo;
7477                                index += 2; /* skipping ID and length bytes; */
7478
7479                                for (i = 0; i < suppRatesNo; i++) {
7480                                        pNewJoinBssParam->supp_rates[i + 1] = pu8IEs[index + i];
7481                                        /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[i+1]); */
7482                                }
7483                                index += suppRatesNo;
7484                                continue;
7485                        }
7486                        /* Ext SupportedRates IE */
7487                        else if (pu8IEs[index] == EXT_SUPP_RATES_IE) {
7488                                /* PRINT_D(HOSTINF_DBG, "Extended Supported Rates\n"); */
7489                                /* checking if no of ext. supp and supp rates < max limit */
7490                                extSuppRatesNo = pu8IEs[index + 1];
7491                                if (extSuppRatesNo > (MAX_RATES_SUPPORTED - suppRatesNo))
7492                                        pNewJoinBssParam->supp_rates[0] = MAX_RATES_SUPPORTED;
7493                                else
7494                                        pNewJoinBssParam->supp_rates[0] += extSuppRatesNo;
7495                                index += 2;
7496                                /* pNewJoinBssParam.supp_rates[0] contains now old number not the ext. no */
7497                                for (i = 0; i < (pNewJoinBssParam->supp_rates[0] - suppRatesNo); i++) {
7498                                        pNewJoinBssParam->supp_rates[suppRatesNo + i + 1] = pu8IEs[index + i];
7499                                        /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[suppRatesNo+i+1]); */
7500                                }
7501                                index += extSuppRatesNo;
7502                                continue;
7503                        }
7504                        /* HT Cap. IE */
7505                        else if (pu8IEs[index] == HT_CAPABILITY_IE) {
7506                                /* if IE found set the flag */
7507                                pNewJoinBssParam->ht_capable = true;
7508                                index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
7509                                /* PRINT_D(HOSTINF_DBG,"HT_CAPABALE\n"); */
7510                                continue;
7511                        } else if ((pu8IEs[index] == WMM_IE) && /* WMM Element ID */
7512                                   (pu8IEs[index + 2] == 0x00) && (pu8IEs[index + 3] == 0x50) &&
7513                                   (pu8IEs[index + 4] == 0xF2) && /* OUI */
7514                                   (pu8IEs[index + 5] == 0x02) && /* OUI Type     */
7515                                   ((pu8IEs[index + 6] == 0x00) || (pu8IEs[index + 6] == 0x01)) && /* OUI Sub Type */
7516                                   (pu8IEs[index + 7] == 0x01)) {
7517                                /* Presence of WMM Info/Param element indicates WMM capability */
7518                                pNewJoinBssParam->wmm_cap = true;
7519
7520                                /* Check if Bit 7 is set indicating U-APSD capability */
7521                                if (pu8IEs[index + 8] & (1 << 7))
7522                                        pNewJoinBssParam->uapsd_cap = true;
7523                                index += pu8IEs[index + 1] + 2;
7524                                continue;
7525                        }
7526                        #ifdef WILC_P2P
7527                        else if ((pu8IEs[index] == P2P_IE) && /* P2P Element ID */
7528                                 (pu8IEs[index + 2] == 0x50) && (pu8IEs[index + 3] == 0x6f) &&
7529                                 (pu8IEs[index + 4] == 0x9a) && /* OUI */
7530                                 (pu8IEs[index + 5] == 0x09) && (pu8IEs[index + 6] == 0x0c)) { /* OUI Type     */
7531                                u16 u16P2P_count;
7532
7533                                pNewJoinBssParam->tsf = ptstrNetworkInfo->u32Tsf;
7534                                pNewJoinBssParam->u8NoaEnbaled = 1;
7535                                pNewJoinBssParam->u8Index = pu8IEs[index + 9];
7536
7537                                /* Check if Bit 7 is set indicating Opss capability */
7538                                if (pu8IEs[index + 10] & (1 << 7)) {
7539                                        pNewJoinBssParam->u8OppEnable = 1;
7540                                        pNewJoinBssParam->u8CtWindow = pu8IEs[index + 10];
7541                                } else
7542                                        pNewJoinBssParam->u8OppEnable = 0;
7543                                /* HOSTINF_DBG */
7544                                PRINT_D(GENERIC_DBG, "P2P Dump\n");
7545                                for (i = 0; i < pu8IEs[index + 7]; i++)
7546                                        PRINT_D(GENERIC_DBG, " %x\n", pu8IEs[index + 9 + i]);
7547
7548                                pNewJoinBssParam->u8Count = pu8IEs[index + 11];
7549                                u16P2P_count = index + 12;
7550
7551                                memcpy(pNewJoinBssParam->au8Duration, pu8IEs + u16P2P_count, 4);
7552                                u16P2P_count += 4;
7553
7554                                memcpy(pNewJoinBssParam->au8Interval, pu8IEs + u16P2P_count, 4);
7555                                u16P2P_count += 4;
7556
7557                                memcpy(pNewJoinBssParam->au8StartTime, pu8IEs + u16P2P_count, 4);
7558
7559                                index += pu8IEs[index + 1] + 2;
7560                                continue;
7561
7562                        }
7563                        #endif
7564                        else if ((pu8IEs[index] == RSN_IE) ||
7565                                 ((pu8IEs[index] == WPA_IE) && (pu8IEs[index + 2] == 0x00) &&
7566                                  (pu8IEs[index + 3] == 0x50) && (pu8IEs[index + 4] == 0xF2) &&
7567                                  (pu8IEs[index + 5] == 0x01))) {
7568                                u16 rsnIndex = index;
7569                                /*PRINT_D(HOSTINF_DBG,"RSN IE Length:%d\n",pu8IEs[rsnIndex+1]);
7570                                 * for(i=0; i<pu8IEs[rsnIndex+1]; i++)
7571                                 * {
7572                                 *      PRINT_D(HOSTINF_DBG,"%0x ",pu8IEs[rsnIndex+2+i]);
7573                                 * }*/
7574                                if (pu8IEs[rsnIndex] == RSN_IE) {
7575                                        pNewJoinBssParam->mode_802_11i = 2;
7576                                        /* PRINT_D(HOSTINF_DBG,"\nRSN_IE\n"); */
7577                                } else { /* check if rsn was previously parsed */
7578                                        if (pNewJoinBssParam->mode_802_11i == 0)
7579                                                pNewJoinBssParam->mode_802_11i = 1;
7580                                        /* PRINT_D(HOSTINF_DBG,"\nWPA_IE\n"); */
7581                                        rsnIndex += 4;
7582                                }
7583                                rsnIndex += 7; /* skipping id, length, version(2B) and first 3 bytes of gcipher */
7584                                pNewJoinBssParam->rsn_grp_policy = pu8IEs[rsnIndex];
7585                                rsnIndex++;
7586                                /* PRINT_D(HOSTINF_DBG,"Group Policy: %0x\n",pNewJoinBssParam->rsn_grp_policy); */
7587                                /* initialize policies with invalid values */
7588
7589                                jumpOffset = pu8IEs[rsnIndex] * 4; /* total no.of bytes of pcipher field (count*4) */
7590
7591                                /*parsing pairwise cipher*/
7592
7593                                /* saving 3 pcipher max. */
7594                                pcipherCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
7595                                rsnIndex += 2; /* jump 2 bytes of pcipher count */
7596
7597                                /* PRINT_D(HOSTINF_DBG,"\npcipher:%d\n",pcipherCount); */
7598                                for (i = pcipherTotalCount, j = 0; i < pcipherCount + pcipherTotalCount && i < 3; i++, j++) {
7599                                        /* each count corresponds to 4 bytes, only last byte is saved */
7600                                        pNewJoinBssParam->rsn_pcip_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
7601                                        /* PRINT_D(HOSTINF_DBG,"PAIR policy = [%0x,%0x]\n",pNewJoinBssParam->rsn_pcip_policy[i],i); */
7602                                }
7603                                pcipherTotalCount += pcipherCount;
7604                                rsnIndex += jumpOffset;
7605
7606                                jumpOffset = pu8IEs[rsnIndex] * 4;
7607
7608                                /*parsing AKM suite (auth_policy)*/
7609                                /* saving 3 auth policies max. */
7610                                authCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
7611                                rsnIndex += 2; /* jump 2 bytes of pcipher count */
7612
7613                                for (i = authTotalCount, j = 0; i < authTotalCount + authCount; i++, j++) {
7614                                        /* each count corresponds to 4 bytes, only last byte is saved */
7615                                        pNewJoinBssParam->rsn_auth_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
7616                                }
7617                                authTotalCount += authCount;
7618                                rsnIndex += jumpOffset;
7619                                /*pasring rsn cap. only if rsn IE*/
7620                                if (pu8IEs[index] == RSN_IE) {
7621                                        pNewJoinBssParam->rsn_cap[0] = pu8IEs[rsnIndex];
7622                                        pNewJoinBssParam->rsn_cap[1] = pu8IEs[rsnIndex + 1];
7623                                        rsnIndex += 2;
7624                                }
7625                                pNewJoinBssParam->rsn_found = true;
7626                                index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
7627                                continue;
7628                        } else
7629                                index += pu8IEs[index + 1] + 2;  /* ID,Length bytes and IE body */
7630
7631                }
7632
7633
7634        }
7635
7636        return (void *)pNewJoinBssParam;
7637
7638}
7639
7640void host_int_freeJoinParams(void *pJoinParams)
7641{
7642        if ((tstrJoinBssParam *)pJoinParams != NULL)
7643                kfree((tstrJoinBssParam *)pJoinParams);
7644        else
7645                PRINT_ER("Unable to FREE null pointer\n");
7646}
7647#endif  /*WILC_PARSE_SCAN_IN_HOST*/
7648
7649
7650/**
7651 *  @brief              host_int_addBASession
7652 *  @details            Open a block Ack session with the given parameters
7653 *  @param[in]          tstrNetworkInfo* ptstrNetworkInfo
7654 *  @return
7655 *  @author             anoureldin
7656 *  @date
7657 *  @version            1.0**/
7658
7659static int host_int_addBASession(tstrWILC_WFIDrv *hWFIDrv, char *pBSSID, char TID, short int BufferSize,
7660                                 short int SessionTimeout, void *drvHandler)
7661{
7662        s32 s32Error = WILC_SUCCESS;
7663        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7664        tstrHostIFmsg strHostIFmsg;
7665        tstrHostIfBASessionInfo *pBASessionInfo = &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo;
7666
7667        if (pstrWFIDrv == NULL)
7668                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7669
7670        memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7671
7672        /* prepare the WiphyParams Message */
7673        strHostIFmsg.u16MsgId = HOST_IF_MSG_ADD_BA_SESSION;
7674
7675        memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
7676        pBASessionInfo->u8Ted = TID;
7677        pBASessionInfo->u16BufferSize = BufferSize;
7678        pBASessionInfo->u16SessionTimeout = SessionTimeout;
7679        strHostIFmsg.drvHandler = hWFIDrv;
7680
7681        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
7682        if (s32Error)
7683                WILC_ERRORREPORT(s32Error, s32Error);
7684        WILC_CATCH(s32Error)
7685        {
7686
7687        }
7688
7689        return s32Error;
7690}
7691
7692
7693s32 host_int_delBASession(tstrWILC_WFIDrv *hWFIDrv, char *pBSSID, char TID)
7694{
7695        s32 s32Error = WILC_SUCCESS;
7696        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7697        tstrHostIFmsg strHostIFmsg;
7698        tstrHostIfBASessionInfo *pBASessionInfo = &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo;
7699
7700        if (pstrWFIDrv == NULL)
7701                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7702
7703        memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7704
7705        /* prepare the WiphyParams Message */
7706        strHostIFmsg.u16MsgId = HOST_IF_MSG_DEL_BA_SESSION;
7707
7708        memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
7709        pBASessionInfo->u8Ted = TID;
7710        strHostIFmsg.drvHandler = hWFIDrv;
7711
7712        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
7713        if (s32Error)
7714                WILC_ERRORREPORT(s32Error, s32Error);
7715        WILC_CATCH(s32Error)
7716        {
7717
7718        }
7719
7720        /*BugID_5222*/
7721        down(&hWaitResponse);
7722
7723        return s32Error;
7724}
7725
7726s32 host_int_del_All_Rx_BASession(tstrWILC_WFIDrv *hWFIDrv, char *pBSSID, char TID)
7727{
7728        s32 s32Error = WILC_SUCCESS;
7729        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7730        tstrHostIFmsg strHostIFmsg;
7731        tstrHostIfBASessionInfo *pBASessionInfo = &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo;
7732
7733        if (pstrWFIDrv == NULL)
7734                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7735
7736        memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7737
7738        /* prepare the WiphyParams Message */
7739        strHostIFmsg.u16MsgId = HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS;
7740
7741        memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
7742        pBASessionInfo->u8Ted = TID;
7743        strHostIFmsg.drvHandler = hWFIDrv;
7744
7745        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
7746        if (s32Error)
7747                WILC_ERRORREPORT(s32Error, s32Error);
7748        WILC_CATCH(s32Error)
7749        {
7750
7751        }
7752
7753        /*BugID_5222*/
7754        down(&hWaitResponse);
7755
7756        return s32Error;
7757}
7758
7759/**
7760 *  @brief              host_int_setup_ipaddress
7761 *  @details            setup IP in firmware
7762 *  @param[in]          Handle to wifi driver
7763 *  @return             Error code.
7764 *  @author             Abdelrahman Sobhy
7765 *  @date
7766 *  @version            1.0*/
7767s32 host_int_setup_ipaddress(tstrWILC_WFIDrv *hWFIDrv, u8 *u16ipadd, u8 idx)
7768{
7769        s32 s32Error = WILC_SUCCESS;
7770        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7771        tstrHostIFmsg strHostIFmsg;
7772
7773        /* TODO: Enable This feature on softap firmware */
7774        return 0;
7775
7776        if (pstrWFIDrv == NULL)
7777                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7778
7779        memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7780
7781        /* prepare the WiphyParams Message */
7782        strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_IPADDRESS;
7783
7784        strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.au8IPAddr = u16ipadd;
7785        strHostIFmsg.drvHandler = hWFIDrv;
7786        strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.idx = idx;
7787
7788        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
7789        if (s32Error)
7790                WILC_ERRORREPORT(s32Error, s32Error);
7791        WILC_CATCH(s32Error)
7792        {
7793
7794        }
7795
7796        return s32Error;
7797
7798
7799}
7800
7801/**
7802 *  @brief              host_int_get_ipaddress
7803 *  @details            Get IP from firmware
7804 *  @param[in]          Handle to wifi driver
7805 *  @return             Error code.
7806 *  @author             Abdelrahman Sobhy
7807 *  @date
7808 *  @version            1.0*/
7809s32 host_int_get_ipaddress(tstrWILC_WFIDrv *hWFIDrv, u8 *u16ipadd, u8 idx)
7810{
7811        s32 s32Error = WILC_SUCCESS;
7812        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7813        tstrHostIFmsg strHostIFmsg;
7814
7815        if (pstrWFIDrv == NULL)
7816                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7817
7818        memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7819
7820        /* prepare the WiphyParams Message */
7821        strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_IPADDRESS;
7822
7823        strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.au8IPAddr = u16ipadd;
7824        strHostIFmsg.drvHandler = hWFIDrv;
7825        strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.idx = idx;
7826
7827        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
7828        if (s32Error)
7829                WILC_ERRORREPORT(s32Error, s32Error);
7830        WILC_CATCH(s32Error)
7831        {
7832
7833        }
7834
7835        return s32Error;
7836
7837
7838}
7839