1981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/*
2981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * systemConfig.c
3981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
4981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved.
5981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * All rights reserved.
6981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
7981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Redistribution and use in source and binary forms, with or without
8981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * modification, are permitted provided that the following conditions
9981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * are met:
10981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
11981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *  * Redistributions of source code must retain the above copyright
12981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *    notice, this list of conditions and the following disclaimer.
13981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *  * Redistributions in binary form must reproduce the above copyright
14981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *    notice, this list of conditions and the following disclaimer in
15981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *    the documentation and/or other materials provided with the
16981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *    distribution.
17981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *  * Neither the name Texas Instruments nor the names of its
18981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *    contributors may be used to endorse or promote products derived
19981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *    from this software without specific prior written permission.
20981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
21981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
33981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
34981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/** \file reportReplvl.c
35981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *  \brief Report level implementation
36981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
37981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *  \see reportReplvl.h
38981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
39981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
40981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/***************************************************************************/
41981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/*																			*/
42981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/*		MODULE:	reportReplvl.c												*/
43981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/*    PURPOSE:	Report level implementation	 								*/
44981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/*																			*/
45981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/***************************************************************************/
46981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define __FILE_ID__  FILE_ID_87
47981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "tidef.h"
48981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "osApi.h"
49981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "siteHash.h"
50981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "sme.h"
51981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "rate.h"
52981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "smeApi.h"
53981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "rsnApi.h"
54981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "report.h"
55981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "TWDriver.h"
56981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "connApi.h"
57981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "DataCtrl_Api.h"
58981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "siteMgrApi.h"
59981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "EvHandler.h"
60981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "TI_IPC_Api.h"
61981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "regulatoryDomainApi.h"
62981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "measurementMgrApi.h"
63981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#ifdef XCC_MODULE_INCLUDED
64981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "XCCMngr.h"
65981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "TransmitPowerXCC.h"
66981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "XCCRMMngr.h"
67981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#endif
68981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
69981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "qosMngr_API.h"
70981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "StaCap.h"
71981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
72981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
73981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/****************************************************************************
74981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt								MATRIC ISSUE
75981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	Each function in the select process returns a MATCH, NO_MATCH value in order to
76981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	skip non relevant sites. In addition, some of the functions also measures a matching level of a site.
77981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	The matching level is returned as a bit map. The select function 'OR's those bit maps in order to
78981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	select the site that has the biggest matching level. If a function returns a NO_MATCH value, the matching level of the
79981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	site is reset.
80981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	Following is the site matching level bit map structure.
81981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	Please notice, that if all the match functions returned MATCH for a site, its matric must be different than 0,
82981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	because of the rates bits.
83981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
84981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
85981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	    31 - 24           23 - 20           20 - 16             15 - 10       9 - 8         7         6           5         4 - 0
86981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	+---------------+---------------+-----------------------+-------------+------------+----------+---------+-----------+-----------+
87981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	| Rx Level      | Privacy       | Attempts              |Rates        | Modulation |Preamble  | Channel | Spectrum  | Reserved  |
88981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	|		        |	    		|		                | 		      |			   |		  |		    | management|		    |
89981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	+---------------+---------------+-----------------------+-------------+------------+----------+---------+-----------+-----------+
90981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt****************************************************************************/
91981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
92981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/* Matric bit map definition */
93981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidttypedef enum
94981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
95981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	/* Rx level */
96981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	METRIC_RX_LEVEL_MASK			= 0xFF,
97981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	METRIC_RX_LEVEL_SHIFT			= 24,
98981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
99981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	/* Privacy */
100981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	METRIC_PRIVACY_MASK				= 0x0F,
101981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	METRIC_PRIVACY_SHIFT			= 20,
102981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
103981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	/* Number of attempts */
104981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	METRIC_ATTEMPTS_NUMBER_MASK		= 0x0F,
105981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	METRIC_ATTEMPTS_NUMBER_SHIFT	= 16,
106981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
107981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
108981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	/* Rates */
109981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	METRIC_RATES_MASK				= 0x3F,
110981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	METRIC_RATES_SHIFT				= 10,
111981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
112981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	/* PBCC */
113981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	METRIC_MODULATION_MASK			= 0x03,
114981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	METRIC_MODULATION_SHIFT			= 8,
115981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
116981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	/* Preamble*/
117981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	METRIC_PREAMBLE_MASK			= 0x01,
118981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	METRIC_PREAMBLE_SHIFT			= 7,
119981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
120981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	/* Channel */
121981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	METRIC_CHANNEL_MASK				= 0x01,
122981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	METRIC_CHANNEL_SHIFT			= 6,
123981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
124981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	/* Spectrum management Capability */
125981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	METRIC_SPECTRUM_MANAGEMENT_MASK	= 0x01,
126981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	METRIC_SPECTRUM_MANAGEMENT_SHIFT= 5,
127981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
128981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	/* Priority Site */
129981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	METRIC_PRIORITY_SITE_MASK		= 0x01,
130981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	METRIC_PRIORITY_SITE_SHIFT		= 4
131981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
132981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt} matric_e;
133981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
134023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt#define MAX_GB_MODE_CHANEL      14
135023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt
136023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt#define MAX_RSN_DATA_SIZE       256
137981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
138981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/* RSSI values boundaries and metric values for best, good, etc  signals */
139981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define SELECT_RSSI_BEST_LEVEL      (-22)
140981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define SELECT_RSSI_GOOD_LEVEL      (-38)
141981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define SELECT_RSSI_NORMAL_LEVEL    (-56)
142981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define SELECT_RSSI_POOR_LEVEL      (-72)
143981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define SELECT_RSSI_BAD_LEVEL       (-82)
144981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
145981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
146981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define  RSSI_METRIC_BEST      6
147981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define  RSSI_METRIC_GOOD      5
148981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define  RSSI_METRIC_NORMAL    4
149981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define  RSSI_METRIC_POOR      3
150981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define  RSSI_METRIC_BAD       2
151981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define  RSSI_METRIC_NOSIGNAL  1
152981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
153981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/* Local functions prototypes */
154981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
155981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic TI_STATUS sendProbeResponse(siteMgr_t *pSiteMgr, TMacAddr *pBssid);
156981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
157981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/* Interface functions Implementation */
158981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
159981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/***********************************************************************
160981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *                        addSelfSite
161981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt ***********************************************************************
162981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtDESCRIPTION: This function is called if the selection fails and desired BSS type is IBSS
163981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt			That means we creating our own network and wait for other stations to join us.
164981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt			the best site for teh station.
165981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt			Performs the following:
166981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt				-	If the desired BSSID is broadcast, we generate a random BSSId, otherwise we use the desired one.
167981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt				-	If the site table is full we remove the most old site
168981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt				-	We send a probe response with our oiwn desired attributes in order to add the site to the site table
169981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
170981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtINPUT:      pSiteMgr	-	site mgr handle.
171981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
172981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtOUTPUT:
173981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
174981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtRETURN:     Pointer to rthe self site entry in the site table
175981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
176981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt************************************************************************/
177981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtsiteEntry_t *addSelfSite(TI_HANDLE hSiteMgr)
178981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
179981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	siteMgr_t       *pSiteMgr = (siteMgr_t *)hSiteMgr;
180981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    siteEntry_t		*pSite;
181981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	TMacAddr		bssid;
182981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TSsid           *pSsid    = &pSiteMgr->pDesiredParams->siteMgrDesiredSSID;
183981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
184981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	if (OS_802_11_SSID_JUNK (pSsid->str, pSsid->len))
185981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		return NULL;
186981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
187981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	if (MAC_BROADCAST (pSiteMgr->pDesiredParams->siteMgrDesiredBSSID))
188981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	{
189981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		MAC_COPY (bssid, pSiteMgr->ibssBssid);
190981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	}
191981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	else
192981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	{
193981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		MAC_COPY (bssid, pSiteMgr->pDesiredParams->siteMgrDesiredBSSID);
194981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	}
195981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
196981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	if(pSiteMgr->pDesiredParams->siteMgrDesiredChannel <= 14)
197981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	{
198981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		pSiteMgr->pSitesMgmtParams->pCurrentSiteTable = &pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables;
199981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pSiteMgr->siteMgrOperationalMode = DOT11_G_MODE;
200981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	}
201981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	else
202981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	{
203981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		pSiteMgr->pSitesMgmtParams->pCurrentSiteTable = (siteTablesParams_t *)&pSiteMgr->pSitesMgmtParams->dot11A_sitesTables;
204981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		pSiteMgr->siteMgrOperationalMode = DOT11_A_MODE;
205981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	}
206981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
207981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    siteMgr_ConfigRate(pSiteMgr);
208981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
209981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	/* First make sure that there is a place in the site table, if not, reomve the eldest site. */
210981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	if (pSiteMgr->pSitesMgmtParams->pCurrentSiteTable->numOfSites == pSiteMgr->pSitesMgmtParams->pCurrentSiteTable->maxNumOfSites)
211981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		removeEldestSite(pSiteMgr);
212981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
213981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	sendProbeResponse(pSiteMgr, &bssid);
214981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
215981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	/* Now find the site in the site table. */
216981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	pSite = findSiteEntry(pSiteMgr, &bssid);
217981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	if (pSite == NULL)
218981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	{
219981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		return NULL;
220981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	}
221981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	pSite->beaconModulation = pSite->probeModulation;
222981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	pSite->barkerPreambleType = PREAMBLE_UNSPECIFIED;
223981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
224981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt   	pSiteMgr->pSitesMgmtParams->pPrimarySite = pSite;
225981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	pSite->siteType = SITE_SELF;
226981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
227981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	return pSite;
228981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
229981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
230981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/***********************************************************************
231981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *                        sendProbeResponse
232981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt ***********************************************************************
233981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtDESCRIPTION: This function is called by the function 'addSelfSite()' in order to send a probe response
234981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt			to the site mgr. This will cause the site manager to add a new entry to the site table, the self site entry.
235981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
236981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtINPUT:      pSiteMgr	-	site mgr handle.
237981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt			pBssid		-	Received BSSID
238981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
239981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtOUTPUT:
240981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
241981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtRETURN:     TI_OK
242981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
243981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt************************************************************************/
244981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic TI_STATUS sendProbeResponse(siteMgr_t *pSiteMgr, TMacAddr *pBssid)
245981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
246981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	mlmeFrameInfo_t		frame;
247023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt    ECipherSuite        rsnStatus;
248981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	dot11_SSID_t 		ssid;
249981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	dot11_RATES_t 		rates;
250981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	dot11_FH_PARAMS_t 	FHParamsSet;
251981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	dot11_DS_PARAMS_t 	DSParamsSet;
252981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	dot11_CF_PARAMS_t 	CFParamsSet;
253981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	dot11_IBSS_PARAMS_t IBSSParamsSet;
254981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	TI_UINT32			len = 0, ofdmIndex = 0;
255981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    ERadioBand          band;
256981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	dot11_RATES_t 		extRates;
257981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	TI_UINT8			ratesBuf[DOT11_MAX_SUPPORTED_RATES];
258981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	TI_BOOL				extRatesInd = TI_FALSE;
259981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
260981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	/* The easiest way to add a site to the site table is to simulate a probe frame. */
261981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	frame.subType = PROBE_RESPONSE;
262981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	os_memoryZero(pSiteMgr->hOs, &frame, sizeof(mlmeFrameInfo_t));
263981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		/* Initialize the frame fields */
264981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	frame.subType = PROBE_RESPONSE;
265981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	os_memoryZero(pSiteMgr->hOs, (void *)frame.content.iePacket.timestamp, TIME_STAMP_LEN);
266981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
267981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	/* Build  Beacon interval  */
268981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	frame.content.iePacket.beaconInerval = pSiteMgr->pDesiredParams->siteMgrDesiredBeaconInterval;
269981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
270981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	/* Build  capability field */
271981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	frame.content.iePacket.capabilities = 0;
272981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	frame.content.iePacket.capabilities |= (TI_TRUE << CAP_IBSS_SHIFT); /* Bss type must be independent */
273981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
274981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	if ((pSiteMgr->pDesiredParams->siteMgrDesiredPreambleType == PREAMBLE_SHORT))
275981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		frame.content.iePacket.capabilities |= (TI_TRUE << CAP_PREAMBLE_SHIFT);
276981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
277981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	/* call RSN to get the privacy desired */
278023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt    rsn_getParamEncryptionStatus(pSiteMgr->hRsn, &rsnStatus); /* RSN_ENCRYPTION_STATUS_PARAM */
279023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt	if (rsnStatus == TWD_CIPHER_NONE)
280981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	{
281981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		frame.content.iePacket.capabilities |= (TI_FALSE << CAP_PRIVACY_SHIFT);
282981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	} else {
283981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		frame.content.iePacket.capabilities |= (TI_TRUE << CAP_PRIVACY_SHIFT);
284981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	}
285981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
286981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	if (pSiteMgr->pDesiredParams->siteMgrDesiredModulationType == DRV_MODULATION_PBCC)
287981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		frame.content.iePacket.capabilities |= (TI_TRUE << CAP_PBCC_SHIFT);
288981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
289981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pSiteMgr->siteMgrOperationalMode == DOT11_G_MODE)
290981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
291981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if(pSiteMgr->pDesiredParams->siteMgrDesiredSlotTime == PHY_SLOT_TIME_SHORT)
292981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            frame.content.iePacket.capabilities |= (TI_TRUE << CAP_SLOT_TIME_SHIFT);
293981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
294981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
295981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	/* Build ssid */
296981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	os_memoryZero(pSiteMgr->hOs, (void *)ssid.serviceSetId, MAX_SSID_LEN);
297981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
298981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	if (pSiteMgr->pDesiredParams->siteMgrDesiredSSID.len == 0)
299981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		ssid.hdr[1] = 0;
300981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	else
301981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	{
302981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		os_memoryCopy(pSiteMgr->hOs, (void *)ssid.serviceSetId, (void *)pSiteMgr->pDesiredParams->siteMgrDesiredSSID.str, pSiteMgr->pDesiredParams->siteMgrDesiredSSID.len);
303981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		ssid.hdr[1] = pSiteMgr->pDesiredParams->siteMgrDesiredSSID.len;
304981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	}
305981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
306981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	if(pSiteMgr->pDesiredParams->siteMgrDesiredChannel <= MAX_GB_MODE_CHANEL)
307981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		siteMgr_updateRates(pSiteMgr, TI_FALSE, TI_TRUE);
308981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	else
309981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		siteMgr_updateRates(pSiteMgr, TI_TRUE, TI_TRUE);
310981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
311981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	/* Build Rates */
312981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	rate_DrvBitmapToNetStr (pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.supportedRateMask,
313981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt						    pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.basicRateMask,
314981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                            ratesBuf,
315981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                            &len,
316981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                            &ofdmIndex);
317981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
318981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	if(pSiteMgr->siteMgrOperationalMode != DOT11_G_MODE ||
319981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt       pSiteMgr->pDesiredParams->siteMgrUseDraftNum == DRAFT_5_AND_EARLIER ||
320981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	   ofdmIndex == len)
321981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	{
322981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		rates.hdr[0] = DOT11_SUPPORTED_RATES_ELE_ID;
323981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		rates.hdr[1] = len;
324981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		os_memoryCopy(pSiteMgr->hOs, (void *)rates.rates, ratesBuf, rates.hdr[1]);
325981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	}
326981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	else
327981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	{
328981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		rates.hdr[0] = DOT11_SUPPORTED_RATES_ELE_ID;
329981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		rates.hdr[1] = ofdmIndex;
330981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		os_memoryCopy(pSiteMgr->hOs, (void *)rates.rates, ratesBuf, rates.hdr[1]);
331981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
332981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		extRates.hdr[0] = DOT11_EXT_SUPPORTED_RATES_ELE_ID;
333981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		extRates.hdr[1] = len - ofdmIndex;
334981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		os_memoryCopy(pSiteMgr->hOs, (void *)extRates.rates, &ratesBuf[ofdmIndex], extRates.hdr[1]);
335981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		extRatesInd = TI_TRUE;
336981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	}
337981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
338981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if((pSiteMgr->siteMgrOperationalMode == DOT11_G_MODE) || (pSiteMgr->siteMgrOperationalMode == DOT11_DUAL_MODE))
339981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
340023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt        erpProtectionType_e protType;
341023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt        ctrlData_getParamProtType(pSiteMgr->hCtrlData, &protType); /* CTRL_DATA_CURRENT_IBSS_PROTECTION_PARAM */
342023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt        frame.content.iePacket.useProtection = protType;
343981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
344981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    else
345981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
346981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        frame.content.iePacket.useProtection = ERP_PROTECTION_NONE;
347981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
348981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
349981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	/* Build FH */
350981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	os_memoryZero(pSiteMgr->hOs, &FHParamsSet, sizeof(dot11_FH_PARAMS_t));
351981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
352981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	/* Build DS */
353981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	DSParamsSet.hdr[1] = 1;
354981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	DSParamsSet.currChannel = pSiteMgr->pDesiredParams->siteMgrDesiredChannel;
355981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
356981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	/* Build CF */
357981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	os_memoryZero(pSiteMgr->hOs, &CFParamsSet, sizeof(dot11_CF_PARAMS_t));
358981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
359981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	/* Build IBSS */
360981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	os_memoryZero(pSiteMgr->hOs, &IBSSParamsSet, sizeof(dot11_IBSS_PARAMS_t));
361981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	IBSSParamsSet.hdr[1] = 2;
362981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	IBSSParamsSet.atimWindow = pSiteMgr->pDesiredParams->siteMgrDesiredAtimWindow;
363981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
364981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	frame.content.iePacket.pSsid = &ssid;
365981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	frame.content.iePacket.pRates = &rates;
366981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
367981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	if(extRatesInd)
368981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		frame.content.iePacket.pExtRates = &extRates;
369981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	else
370981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		frame.content.iePacket.pExtRates = NULL;
371981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
372981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	frame.content.iePacket.pFHParamsSet = &FHParamsSet;
373981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	frame.content.iePacket.pDSParamsSet = &DSParamsSet;
374981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	frame.content.iePacket.pCFParamsSet = &CFParamsSet;
375981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	frame.content.iePacket.pIBSSParamsSet = &IBSSParamsSet;
376981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
377981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    band = ( MAX_GB_MODE_CHANEL >= pSiteMgr->pDesiredParams->siteMgrDesiredChannel ? RADIO_BAND_2_4_GHZ : RADIO_BAND_5_0_GHZ );
378981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	/* Update site */
379981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	siteMgr_updateSite(pSiteMgr, pBssid, &frame ,pSiteMgr->pDesiredParams->siteMgrDesiredChannel, band, TI_FALSE);
380981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
381981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	return TI_OK;
382981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
383981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
384981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/***********************************************************************
385981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *                        systemConfig
386981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt ***********************************************************************
387981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtDESCRIPTION: This function is called by the function 'siteMgr_selectSite()' in order to configure
388981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt			the system with the chosen site attribute.
389981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
390981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtINPUT:      pSiteMgr	-	site mgr handle.
391981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
392981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtOUTPUT:
393981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
394981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtRETURN:     TI_OK
395981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
396981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt************************************************************************/
397981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtTI_STATUS systemConfig(siteMgr_t *pSiteMgr)
398981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
399023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt	paramInfo_t *pParam;
400981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	siteEntry_t *pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
401981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	TRsnData	rsnData;
402981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	TI_UINT8	rsnAssocIeLen;
403981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    dot11_RSN_t *pRsnIe;
404981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_UINT8    rsnIECount=0;
405023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt    TI_UINT8    *curRsnData;
406981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_UINT16   length;
407981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_UINT16   capabilities;
408981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_UINT16   PktLength=0;
409981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_UINT8	*pIeBuffer=NULL;
410981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_BOOL     b11nEnable;
411981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_BOOL     bWmeEnable;
412981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
413981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#ifdef XCC_MODULE_INCLUDED
414981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_UINT8     ExternTxPower;
415981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#endif
416981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	TI_STATUS	status;
417981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	ESlotTime	slotTime;
418981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	TI_UINT32	StaTotalRates;
419981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	dot11_ACParameters_t *p_ACParametersDummy = NULL;
420981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TtxCtrlHtControl tHtControl;
421981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
422023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt    curRsnData = os_memoryAlloc(pSiteMgr->hOs, MAX_RSN_DATA_SIZE);
423023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt    if (!curRsnData)
424023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt        return TI_NOK;
425023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt    pParam = (paramInfo_t *)os_memoryAlloc(pSiteMgr->hOs, sizeof(paramInfo_t));
426023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt    if (!pParam) {
427023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt        os_memoryFree(pSiteMgr->hOs, curRsnData, MAX_RSN_DATA_SIZE);
428023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt        return TI_NOK;
429023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt    }
430023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt
431981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	if (pPrimarySite->probeRecv)
432981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	{
433981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		pIeBuffer = pPrimarySite->probeRespBuffer;
434981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		PktLength = pPrimarySite->probeRespLength;
435981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	}
436981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    else if (pPrimarySite->beaconRecv)
437981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	{
438981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		pIeBuffer = pPrimarySite->beaconBuffer;
439981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		PktLength = pPrimarySite->beaconLength;
440981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	}
441981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
442981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	pSiteMgr->prevRadioBand = pSiteMgr->radioBand;
443981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
444981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TRACE2(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Capabilities, Slot Time Bit = %d (capabilities = %d)\n", (pPrimarySite->capabilities >> CAP_SLOT_TIME_SHIFT) & 1, pPrimarySite->capabilities);
445981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
446981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	if(pPrimarySite->channel <= MAX_GB_MODE_CHANEL)
447981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	{
448981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		if(pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode == DOT11_B_MODE)
449981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		{
450981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt			pSiteMgr->siteMgrOperationalMode = DOT11_B_MODE;
451981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt			slotTime = PHY_SLOT_TIME_LONG;
452981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
453981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            TRACE1(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, ": 11b Mode, Slot Time = %d\n", (TI_UINT8)slotTime);
454981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		}
455981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		else
456981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		{
457981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt			pSiteMgr->siteMgrOperationalMode = DOT11_G_MODE;
458981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
459981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt			if (((pPrimarySite->capabilities >> CAP_SLOT_TIME_SHIFT) & CAP_SLOT_TIME_MASK) == PHY_SLOT_TIME_SHORT)
460981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt			{
461981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt			slotTime = pSiteMgr->pDesiredParams->siteMgrDesiredSlotTime;
462981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
463981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            TRACE1(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, ": 11g Mode, Slot Time = %d (desired)\n", (TI_UINT8)slotTime);
464981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt			}
465981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt			else
466981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt			{
467981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt				slotTime = PHY_SLOT_TIME_LONG;
468981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
469981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                TRACE1(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, ": 11g Mode, Slot Time = %d\n", (TI_UINT8) slotTime);
470981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt			}
471981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		}
472981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
473981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		pSiteMgr->radioBand = RADIO_BAND_2_4_GHZ;
474981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		pSiteMgr->pSitesMgmtParams->pCurrentSiteTable = &pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables;
475981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	}
476981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	else
477981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	{
478981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		pSiteMgr->siteMgrOperationalMode = DOT11_A_MODE;
479981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		pSiteMgr->radioBand = RADIO_BAND_5_0_GHZ;
480981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		slotTime = PHY_SLOT_TIME_SHORT;
481981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
482981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        TRACE1(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, ": 11a Mode, Slot Time = %d\n", (TI_UINT8)slotTime);
483981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
484981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		pSiteMgr->pSitesMgmtParams->pCurrentSiteTable = (siteTablesParams_t *)&pSiteMgr->pSitesMgmtParams->dot11A_sitesTables;
485981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	}
486981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
487981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	/* since we are moving to the different band, the siteMgr should be reconfigured */
488981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	if(pSiteMgr->prevRadioBand != pSiteMgr->radioBand)
489981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		siteMgr_bandParamsConfig(pSiteMgr, TI_TRUE);
490981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
491981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	if(pPrimarySite->channel <= MAX_GB_MODE_CHANEL)
492981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		siteMgr_updateRates(pSiteMgr, TI_FALSE, TI_TRUE);
493981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	else
494981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		siteMgr_updateRates(pSiteMgr, TI_TRUE, TI_TRUE);
495981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
496981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	/* configure hal with common core-hal parameters */
497981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	TWD_SetRadioBand (pSiteMgr->hTWD, pSiteMgr->radioBand);
498981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
499981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	pPrimarySite->currentSlotTime = slotTime;
500981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	TWD_CfgSlotTime (pSiteMgr->hTWD, slotTime);
501981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
502981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	/***************** Config Site Manager *************************/
503981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	/* L.M. Should be fixed, should take into account the AP's rates */
504981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	if(pSiteMgr->pDesiredParams->siteMgrDesiredModulationType == DRV_MODULATION_CCK)
505981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		pSiteMgr->chosenModulation = DRV_MODULATION_CCK;
506981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	else if(pSiteMgr->pDesiredParams->siteMgrDesiredModulationType == DRV_MODULATION_PBCC)
507981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	{
508981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		if(pPrimarySite->probeModulation != DRV_MODULATION_NONE)
509981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt			pSiteMgr->chosenModulation = pPrimarySite->probeModulation;
510981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		else
511981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt			pSiteMgr->chosenModulation = pPrimarySite->beaconModulation;
512981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	}
513981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	else
514981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		pSiteMgr->chosenModulation = DRV_MODULATION_OFDM;
515981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
516981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	/* We use this variable in order tp perform the PBCC algorithm. */
517981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	pSiteMgr->currentDataModulation = pSiteMgr->chosenModulation;
518981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	/***************** Config Data CTRL *************************/
519981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
520023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt	pParam->paramType = CTRL_DATA_CURRENT_BSSID_PARAM;							/* Current BSSID */
521023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt	MAC_COPY (pParam->content.ctrlDataCurrentBSSID, pPrimarySite->bssid);
522023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt	ctrlData_setParam(pSiteMgr->hCtrlData, pParam);
523981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
524023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt	pParam->paramType = CTRL_DATA_CURRENT_BSS_TYPE_PARAM;							/* Current BSS Type */
525023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt	pParam->content.ctrlDataCurrentBssType = pPrimarySite->bssType;
526023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt	ctrlData_setParam(pSiteMgr->hCtrlData, pParam);
527981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
528023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt	pParam->paramType = CTRL_DATA_CURRENT_PREAMBLE_TYPE_PARAM;					/* Current Preamble Type */
529981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	if ((pSiteMgr->pDesiredParams->siteMgrDesiredPreambleType == PREAMBLE_SHORT) &&
530981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		(pPrimarySite->currentPreambleType == PREAMBLE_SHORT))
531023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt		pParam->content.ctrlDataCurrentPreambleType = PREAMBLE_SHORT;
532981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	else
533023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt		pParam->content.ctrlDataCurrentPreambleType = PREAMBLE_LONG;
534023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt	ctrlData_setParam(pSiteMgr->hCtrlData, pParam);
535981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
536981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Mutual Rates Matching */
537981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	StaTotalRates = pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.basicRateMask |
538981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt					pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.supportedRateMask;
539981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
540981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
541981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pSiteMgr->pDesiredParams->siteMgrMatchedSuppRateMask = StaTotalRates &
542981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt														   pPrimarySite->rateMask.supportedRateMask;
543981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
544981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	pSiteMgr->pDesiredParams->siteMgrMatchedBasicRateMask = StaTotalRates &
545981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt															pPrimarySite->rateMask.basicRateMask;
546981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	if (pSiteMgr->pDesiredParams->siteMgrMatchedBasicRateMask == 0)
547981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	{
548981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		pSiteMgr->pDesiredParams->siteMgrMatchedBasicRateMask =
549981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt			pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.basicRateMask;
550981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	}
551981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
552981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* set protection */
553981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if(BSS_INDEPENDENT == pPrimarySite->bssType)
554981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
555023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt        pParam->paramType = CTRL_DATA_CURRENT_IBSS_PROTECTION_PARAM;
556981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
557981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    else
558981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
559023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt        pParam->paramType = CTRL_DATA_CURRENT_PROTECTION_STATUS_PARAM;
560981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
561023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt    pParam->content.ctrlDataProtectionEnabled = pPrimarySite->useProtection;
562023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt    ctrlData_setParam(pSiteMgr->hCtrlData, pParam);
563981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
564981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	pbccAlgorithm(pSiteMgr);
565981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
566981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	/********** Set Site QOS protocol support *************/
567981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
568981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	/* Set WME Params */
569981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	 status = siteMgr_getWMEParamsSite(pSiteMgr,&p_ACParametersDummy);
570981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	 if(status == TI_OK)
571981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	 {
572023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt		 pParam->content.qosSiteProtocol = QOS_WME;
573981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	 }
574981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	 else
575981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	 {
576023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt		 pParam->content.qosSiteProtocol = QOS_NONE;
577981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	 }
578981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
579023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt     TRACE1(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, " systemConfigt() : pParam->content.qosSiteProtoco %d\n", pParam->content.qosSiteProtocol);
580981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
581023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt	 pParam->paramType = QOS_MNGR_SET_SITE_PROTOCOL;
582023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt	 qosMngr_setParams(pSiteMgr->hQosMngr, pParam);
583981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
584981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     /* Set active protocol in qosMngr according to station desired mode and site capabilities
585023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt	    Must be called BEFORE setting the "CURRENT_PS_MODE" into the QosMngr */
586981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     qosMngr_selectActiveProtocol(pSiteMgr->hQosMngr);
587981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
588981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	 /* set PS capability parameter */
589023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt	 pParam->paramType = QOS_MNGR_CURRENT_PS_MODE;
590981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	 if(pPrimarySite->APSDSupport == TI_TRUE)
591023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt		 pParam->content.currentPsMode = PS_SCHEME_UPSD_TRIGGER;
592981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	 else
593023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt		 pParam->content.currentPsMode = PS_SCHEME_LEGACY;
594023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt      qosMngr_setParams(pSiteMgr->hQosMngr, pParam);
595981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
596981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     /* Set upsd/ps_poll configuration */
597981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     /* Must be done AFTER setting the active Protocol */
598981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     qosMngr_setAcPsDeliveryMode (pSiteMgr->hQosMngr);
599981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
600981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
601981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     /********** Set Site HT setting support *************/
602981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     /* set HT setting to the FW */
603981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     /* verify 11n_Enable and Chip type */
604981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     StaCap_IsHtEnable (pSiteMgr->hStaCap, &b11nEnable);
605981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
606981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     /* verify that WME flag enable */
607981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     qosMngr_GetWmeEnableFlag (pSiteMgr->hQosMngr, &bWmeEnable);
608981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
609981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     if ((b11nEnable != TI_FALSE) &&
610981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         (bWmeEnable != TI_FALSE) &&
611981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         (pPrimarySite->tHtCapabilities.tHdr[0] != TI_FALSE) &&
612981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         (pPrimarySite->tHtInformation.tHdr[0] != TI_FALSE))
613981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     {
614981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         TWD_CfgSetFwHtCapabilities (pSiteMgr->hTWD, &pPrimarySite->tHtCapabilities, TI_TRUE);
615981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         TWD_CfgSetFwHtInformation (pSiteMgr->hTWD, &pPrimarySite->tHtInformation);
616981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
617981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         /* the FW not supported in HT control field in TX */
618981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
619981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        tHtControl.bHtEnable = TI_FALSE;
620981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         txCtrlParams_SetHtControl (pSiteMgr->hTxCtrl, &tHtControl);
621981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     }
622981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     else
623981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     {
624981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         TWD_CfgSetFwHtCapabilities (pSiteMgr->hTWD, &pPrimarySite->tHtCapabilities, TI_FALSE);
625981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
626981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         tHtControl.bHtEnable = TI_FALSE;
627981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         txCtrlParams_SetHtControl (pSiteMgr->hTxCtrl, &tHtControl);
628981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     }
629981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
630981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	/***************** Config RSN *************************/
631981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Get the RSN IE data */
632981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pRsnIe = pPrimarySite->pRsnIe;
633023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt	length = 0;
634981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    rsnIECount = 0;
635981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    while ((length < pPrimarySite->rsnIeLen) && (pPrimarySite->rsnIeLen < 255)
636981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt           && (rsnIECount < MAX_RSN_IE))
637981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
638981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        curRsnData[0+length] = pRsnIe->hdr[0];
639981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        curRsnData[1+length] = pRsnIe->hdr[1];
640981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        os_memoryCopy(pSiteMgr->hOs, &curRsnData[2+length], (void *)pRsnIe->rsnIeData, pRsnIe->hdr[1]);
641981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        length += pRsnIe->hdr[1]+2;
642981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pRsnIe += 1;
643981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        rsnIECount++;
644981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
645981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (length<pPrimarySite->rsnIeLen)
646981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
647981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        TRACE2(pSiteMgr->hReport, REPORT_SEVERITY_ERROR, "siteMgr_selectSiteFromTable, RSN IE is too long: rsnIeLen=%d, MAX_RSN_IE=%d\n", pPrimarySite->rsnIeLen, MAX_RSN_IE);
648981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
649981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
650023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt	rsnData.pIe = (pPrimarySite->rsnIeLen==0) ? NULL : curRsnData;
651981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	rsnData.ieLen = pPrimarySite->rsnIeLen;
652981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    rsnData.privacy = pPrimarySite->privacy;
653981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
654981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    rsn_setSite(pSiteMgr->hRsn, &rsnData, NULL, &rsnAssocIeLen);
655981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
656981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	/***************** Config RegulatoryDomain **************************/
657981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
658981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#ifdef XCC_MODULE_INCLUDED
659981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	/* set XCC TPC if present */
660981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	if(XCC_ParseClientTP(pSiteMgr->hOs,pPrimarySite,&ExternTxPower,pIeBuffer,PktLength) == TI_OK)
661981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
662981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        TRACE1(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "Select XCC_ParseClientTP == OK: Dbm = %d\n",ExternTxPower);
663023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt        pParam->paramType = REGULATORY_DOMAIN_EXTERN_TX_POWER_PREFERRED;
664023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt        pParam->content.ExternTxPowerPreferred = ExternTxPower;
665023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt        regulatoryDomain_setParam(pSiteMgr->hRegulatoryDomain, pParam);
666981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
667981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	/* Parse and save the XCC Version Number if exists */
668981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	XCCMngr_parseXCCVer(pSiteMgr->hXCCMngr, pIeBuffer, PktLength);
669981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
670981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#endif
671981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
672981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	/* Note: TX Power Control adjustment is now done through siteMgr_assocReport() */
673981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	if (pPrimarySite->powerConstraint>0)
674981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	{	/* setting power constraint */
675023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt		pParam->paramType = REGULATORY_DOMAIN_SET_POWER_CONSTRAINT_PARAM;
676023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt		pParam->content.powerConstraint = pPrimarySite->powerConstraint;
677023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt		regulatoryDomain_setParam(pSiteMgr->hRegulatoryDomain, pParam);
678981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	}
679981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
680981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
681981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	/***************** Config MeasurementMgr object **************************/
682981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    capabilities = pPrimarySite->capabilities;
683981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
684981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Updating the Measurement Module Mode */
685981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    measurementMgr_setMeasurementMode(pSiteMgr->hMeasurementMgr, capabilities,
686981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt									pIeBuffer, PktLength);
687023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt    os_memoryFree(pSiteMgr->hOs, curRsnData, MAX_RSN_DATA_SIZE);
688023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt    os_memoryFree(pSiteMgr->hOs, pParam, sizeof(paramInfo_t));
689981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	return TI_OK;
690981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
691981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
692