wlan_p2p.c 62 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838
  1. /*
  2. ** Id: //Department/DaVinci/TRUNK/WiFi_P2P_Driver/common/wlan_p2p.c#8
  3. */
  4. /*! \file wlan_bow.c
  5. \brief This file contains the Wi-Fi Direct commands processing routines for
  6. MediaTek Inc. 802.11 Wireless LAN Adapters.
  7. */
  8. /*
  9. ** Log: wlan_p2p.c
  10. **
  11. ** 04 21 2015 eason.tsai
  12. ** [ALPS02012000] [MT6795][L-MR1][NFC][Beam Plus][Blocking]The picture will not transfer
  13. **
  14. ** 03 07 2014 eason.tsai
  15. ** [ALPS01070904] [Need Patch] [Volunteer Patch][MT6630][Driver]MT6630 Wi-Fi Patch
  16. ** fix ap mode crash by hotspot only set_beacon without chenge_interface
  17. **
  18. ** 10 08 2013 yuche.tsai
  19. ** [ALPS01065606] [Volunteer Patch][MT6630][Wi-Fi Direct][Driver] MT6630 Wi-Fi Direct Driver Patch
  20. ** Update Wi-Fi Direct Source.
  21. **
  22. ** 07 23 2013 wh.su
  23. ** [BORA00002446] [MT6630] [Wi-Fi] [Driver] Update the security function code
  24. ** Modify some security code for 11w and p2p
  25. **
  26. ** 03 12 2013 wh.su
  27. ** [BORA00002446] [MT6630] [Wi-Fi] [Driver] Update the security function code
  28. ** .
  29. **
  30. ** 03 07 2013 yuche.tsai
  31. ** [BORA00002398] [MT6630][Volunteer Patch] P2P Driver Re-Design for Multiple BSS support
  32. ** Add wlan_p2p.c, but still need to FIX many place.
  33. **
  34. ** 11 21 2012 terry.wu
  35. ** [BORA00002207] [MT6630 Wi-Fi] TXM & MQM Implementation
  36. ** [Driver] Fix linux drvier build error.
  37. **
  38. ** 09 17 2012 cm.chang
  39. ** [BORA00002149] [MT6630 Wi-Fi] Initial software development
  40. ** Duplicate source from MT6620 v2.3 driver branch
  41. ** (Davinci label: MT6620_WIFI_Driver_V2_3_120913_1942_As_MT6630_Base)
  42. *
  43. * 07 17 2012 yuche.tsai
  44. * NULL
  45. * Compile no error before trial run.
  46. *
  47. * 11 24 2011 yuche.tsai
  48. * NULL
  49. * Fix P2P IOCTL of multicast address bug, add low power driver stop control.
  50. *
  51. * 11 22 2011 yuche.tsai
  52. * NULL
  53. * Update RSSI link quality of P2P Network query method. (Bug fix)
  54. *
  55. * 11 19 2011 yuche.tsai
  56. * NULL
  57. * Add RSSI support for P2P network.
  58. *
  59. * 11 08 2011 yuche.tsai
  60. * [WCXRP00001094] [Volunteer Patch][Driver] Driver version & supplicant version query & set support
  61. * for service discovery version check.
  62. * Add support for driver version query & p2p supplicant verseion set.
  63. * For new service discovery mechanism sync.
  64. *
  65. * 10 18 2011 yuche.tsai
  66. * [WCXRP00001045] [WiFi Direct][Driver] Check 2.1 branch.
  67. * Support Channel Query.
  68. *
  69. * 10 18 2011 yuche.tsai
  70. * [WCXRP00001045] [WiFi Direct][Driver] Check 2.1 branch.
  71. * New 2.1 branch
  72. *
  73. * 08 23 2011 yuche.tsai
  74. * NULL
  75. * Fix Multicast Issue of P2P.
  76. *
  77. * 04 27 2011 george.huang
  78. * [WCXRP00000684] [MT6620 Wi-Fi][Driver] Support P2P setting ARP filter
  79. * Support P2P ARP filter setting on early suspend/ late resume
  80. *
  81. * 04 08 2011 george.huang
  82. * [WCXRP00000621] [MT6620 Wi-Fi][Driver] Support P2P supplicant to set power mode
  83. * separate settings of P2P and AIS
  84. *
  85. * 03 22 2011 george.huang
  86. * [WCXRP00000504] [MT6620 Wi-Fi][FW] Support Sigma CAPI for power saving related command
  87. * link with supplicant commands
  88. *
  89. * 03 17 2011 wh.su
  90. * [WCXRP00000571] [MT6620 Wi-Fi] [Driver] Not check the p2p role during set key
  91. * Skip the p2p role for adding broadcast key issue.
  92. *
  93. * 03 16 2011 wh.su
  94. * [WCXRP00000530] [MT6620 Wi-Fi] [Driver] skip doing p2pRunEventAAAComplete after send assoc response Tx Done
  95. * fixed compiling error while enable dbg.
  96. *
  97. * 03 08 2011 yuche.tsai
  98. * [WCXRP00000480] [Volunteer Patch][MT6620][Driver] WCS IE format
  99. * issue[WCXRP00000509] [Volunteer Patch][MT6620][Driver] Kernal panic when remove p2p module.
  100. * .
  101. *
  102. * 03 07 2011 terry.wu
  103. * [WCXRP00000521] [MT6620 Wi-Fi][Driver] Remove non-standard debug message
  104. * Toggle non-standard debug messages to comments.
  105. *
  106. * 03 07 2011 wh.su
  107. * [WCXRP00000506] [MT6620 Wi-Fi][Driver][FW] Add Security check related code
  108. * rename the define to anti_pviracy.
  109. *
  110. * 03 05 2011 wh.su
  111. * [WCXRP00000506] [MT6620 Wi-Fi][Driver][FW] Add Security check related code
  112. * add the code to get the check rsponse and indicate to app.
  113. *
  114. * 03 02 2011 wh.su
  115. * [WCXRP00000506] [MT6620 Wi-Fi][Driver][FW] Add Security check related code
  116. * Add Security check related code.
  117. *
  118. * 03 02 2011 yuche.tsai
  119. * [WCXRP00000245] 1. Invitation Request/Response.
  120. 2. Provision Discovery Request/Response
  121. * Fix SD Request Query Length issue.
  122. *
  123. * 03 02 2011 yuche.tsai
  124. * [WCXRP00000245] 1. Invitation Request/Response.
  125. 2. Provision Discovery Request/Response
  126. * Service Discovery Request.
  127. *
  128. * 03 01 2011 yuche.tsai
  129. * [WCXRP00000245] 1. Invitation Request/Response.
  130. 2. Provision Discovery Request/Response
  131. * Update Service Discovery Wlan OID related function.
  132. *
  133. * 03 01 2011 yuche.tsai
  134. * [WCXRP00000245] 1. Invitation Request/Response.
  135. 2. Provision Discovery Request/Response
  136. * Update Service Discovery Related wlanoid function.
  137. *
  138. * 02 09 2011 yuche.tsai
  139. * [WCXRP00000245] 1. Invitation Request/Response.
  140. 2. Provision Discovery Request/Response
  141. * Add Service Discovery Indication Related code.
  142. *
  143. * 01 26 2011 yuche.tsai
  144. * [WCXRP00000245] 1. Invitation Request/Response.
  145. 2. Provision Discovery Request/Response
  146. * Add Service Discovery Function.
  147. *
  148. * 01 05 2011 cp.wu
  149. * [WCXRP00000283] [MT6620 Wi-Fi][Driver][Wi-Fi Direct] Implementation of interface
  150. * for supporting Wi-Fi Direct Service Discovery ioctl implementations for P2P Service Discovery
  151. *
  152. * 01 04 2011 cp.wu
  153. * [WCXRP00000338] [MT6620 Wi-Fi][Driver] Separate kalMemAlloc into kmalloc and vmalloc implementations to
  154. * ease physically continuous memory demands separate kalMemAlloc() into virtually-continuous
  155. * and physically-continuous type to ease slab system pressure
  156. *
  157. * 12 22 2010 cp.wu
  158. * [WCXRP00000283] [MT6620 Wi-Fi][Driver][Wi-Fi Direct] Implementation of interface
  159. * for supporting Wi-Fi Direct Service Discovery
  160. * 1. header file restructure for more clear module isolation
  161. * 2. add function interface definition for implementing Service Discovery callbacks
  162. *
  163. * 10 04 2010 cp.wu
  164. * [WCXRP00000077] [MT6620 Wi-Fi][Driver][FW] Eliminate use of ENUM_NETWORK_TYPE_T
  165. * and replaced by ENUM_NETWORK_TYPE_INDEX_T only remove ENUM_NETWORK_TYPE_T definitions
  166. *
  167. * 09 28 2010 wh.su
  168. * NULL
  169. * [WCXRP00000069][MT6620 Wi-Fi][Driver] Fix some code for phase 1 P2P Demo.
  170. *
  171. * 09 21 2010 kevin.huang
  172. * [WCXRP00000054] [MT6620 Wi-Fi][Driver] Restructure driver for second Interface
  173. * Isolate P2P related function for Hardware Software Bundle
  174. *
  175. * 09 03 2010 kevin.huang
  176. * NULL
  177. * Refine #include sequence and solve recursive/nested #include issue
  178. *
  179. * 08 23 2010 cp.wu
  180. * NULL
  181. * revise constant definitions to be matched with implementation (original cmd-event definition is deprecated)
  182. *
  183. * 08 16 2010 cp.wu
  184. * NULL
  185. * add subroutines for P2P to set multicast list.
  186. *
  187. * 08 16 2010 george.huang
  188. * NULL
  189. * .
  190. *
  191. * 08 16 2010 george.huang
  192. * NULL
  193. * support wlanoidSetP2pPowerSaveProfile() in P2P
  194. *
  195. * 08 16 2010 george.huang
  196. * NULL
  197. * Support wlanoidSetNetworkAddress() for P2P
  198. *
  199. * 07 08 2010 cp.wu
  200. *
  201. * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
  202. *
  203. * 06 25 2010 cp.wu
  204. * [WPD00003833][MT6620 and MT5931] Driver migration
  205. * add API in que_mgt to retrieve sta-rec index for security frames.
  206. *
  207. * 06 24 2010 cp.wu
  208. * [WPD00003833][MT6620 and MT5931] Driver migration
  209. * 802.1x and bluetooth-over-Wi-Fi security frames are now delievered to firmware via command path instead of data path.
  210. *
  211. * 06 11 2010 cp.wu
  212. * [WPD00003833][MT6620 and MT5931] Driver migration
  213. * 1) migrate assoc.c.
  214. * 2) add ucTxSeqNum for tracking frames which needs TX-DONE awareness
  215. * 3) add configuration options for CNM_MEM and RSN modules
  216. * 4) add data path for management frames
  217. * 5) eliminate rPacketInfo of MSDU_INFO_T
  218. *
  219. * 06 06 2010 kevin.huang
  220. * [WPD00003832][MT6620 5931] Create driver base
  221. * [MT6620 5931] Create driver base
  222. *
  223. * 05 17 2010 cp.wu
  224. * [WPD00003831][MT6620 Wi-Fi] Add framework for Wi-Fi Direct support
  225. * 1) add timeout handler mechanism for pending command packets
  226. * 2) add p2p add/removal key
  227. *
  228. **
  229. */
  230. /******************************************************************************
  231. * C O M P I L E R F L A G S
  232. *******************************************************************************
  233. */
  234. /******************************************************************************
  235. * E X T E R N A L R E F E R E N C E S
  236. *******************************************************************************
  237. */
  238. #include "precomp.h"
  239. #include "gl_p2p_ioctl.h"
  240. /******************************************************************************
  241. * C O N S T A N T S
  242. *******************************************************************************
  243. */
  244. /******************************************************************************
  245. * D A T A T Y P E S
  246. *******************************************************************************
  247. */
  248. /******************************************************************************
  249. * P U B L I C D A T A
  250. *******************************************************************************
  251. */
  252. /******************************************************************************
  253. * P R I V A T E D A T A
  254. *******************************************************************************
  255. */
  256. /******************************************************************************
  257. * M A C R O S
  258. *******************************************************************************
  259. */
  260. /******************************************************************************
  261. * F U N C T I O N D E C L A R A T I O N S
  262. *******************************************************************************
  263. */
  264. /******************************************************************************
  265. * F U N C T I O N S
  266. *******************************************************************************
  267. */
  268. /*----------------------------------------------------------------------------*/
  269. /*!
  270. * \brief command packet generation utility
  271. *
  272. * \param[in] prAdapter Pointer to the Adapter structure.
  273. * \param[in] ucCID Command ID
  274. * \param[in] fgSetQuery Set or Query
  275. * \param[in] fgNeedResp Need for response
  276. * \param[in] pfCmdDoneHandler Function pointer when command is done
  277. * \param[in] u4SetQueryInfoLen The length of the set/query buffer
  278. * \param[in] pucInfoBuffer Pointer to set/query buffer
  279. *
  280. *
  281. * \retval WLAN_STATUS_PENDING
  282. * \retval WLAN_STATUS_FAILURE
  283. */
  284. /*----------------------------------------------------------------------------*/
  285. WLAN_STATUS
  286. wlanoidSendSetQueryP2PCmd(IN P_ADAPTER_T prAdapter,
  287. IN UINT_8 ucCID,
  288. IN UINT_8 ucBssIdx,
  289. IN BOOLEAN fgSetQuery,
  290. IN BOOLEAN fgNeedResp,
  291. IN BOOLEAN fgIsOid,
  292. IN PFN_CMD_DONE_HANDLER pfCmdDoneHandler,
  293. IN PFN_CMD_TIMEOUT_HANDLER pfCmdTimeoutHandler,
  294. IN UINT_32 u4SetQueryInfoLen,
  295. IN PUINT_8 pucInfoBuffer, OUT PVOID pvSetQueryBuffer, IN UINT_32 u4SetQueryBufferLen)
  296. {
  297. P_GLUE_INFO_T prGlueInfo;
  298. P_CMD_INFO_T prCmdInfo;
  299. P_WIFI_CMD_T prWifiCmd;
  300. UINT_8 ucCmdSeqNum;
  301. ASSERT(prAdapter);
  302. prGlueInfo = prAdapter->prGlueInfo;
  303. ASSERT(prGlueInfo);
  304. DEBUGFUNC("wlanoidSendSetQueryP2PCmd");
  305. DBGLOG(REQ, TRACE, "Command ID = 0x%08X\n", ucCID);
  306. prCmdInfo = cmdBufAllocateCmdInfo(prAdapter, (CMD_HDR_SIZE + u4SetQueryInfoLen));
  307. if (!prCmdInfo) {
  308. DBGLOG(INIT, ERROR, "Allocate CMD_INFO_T ==> FAILED.\n");
  309. return WLAN_STATUS_FAILURE;
  310. }
  311. /* increase command sequence number */
  312. ucCmdSeqNum = nicIncreaseCmdSeqNum(prAdapter);
  313. DBGLOG(REQ, TRACE, "ucCmdSeqNum =%d\n", ucCmdSeqNum);
  314. /* Setup common CMD Info Packet */
  315. prCmdInfo->eCmdType = COMMAND_TYPE_NETWORK_IOCTL;
  316. prCmdInfo->ucBssIndex = ucBssIdx;
  317. prCmdInfo->u2InfoBufLen = (UINT_16) (CMD_HDR_SIZE + u4SetQueryInfoLen);
  318. prCmdInfo->pfCmdDoneHandler = pfCmdDoneHandler;
  319. prCmdInfo->pfCmdTimeoutHandler = pfCmdTimeoutHandler;
  320. prCmdInfo->fgIsOid = fgIsOid;
  321. prCmdInfo->ucCID = ucCID;
  322. prCmdInfo->fgSetQuery = fgSetQuery;
  323. prCmdInfo->fgNeedResp = fgNeedResp;
  324. prCmdInfo->fgDriverDomainMCR = FALSE;
  325. prCmdInfo->ucCmdSeqNum = ucCmdSeqNum;
  326. prCmdInfo->u4SetInfoLen = u4SetQueryInfoLen;
  327. prCmdInfo->pvInformationBuffer = pvSetQueryBuffer;
  328. prCmdInfo->u4InformationBufferLength = u4SetQueryBufferLen;
  329. /* Setup WIFI_CMD_T (no payload) */
  330. prWifiCmd = (P_WIFI_CMD_T) (prCmdInfo->pucInfoBuffer);
  331. prWifiCmd->u2TxByteCount = prCmdInfo->u2InfoBufLen;
  332. prWifiCmd->ucCID = prCmdInfo->ucCID;
  333. prWifiCmd->ucSetQuery = prCmdInfo->fgSetQuery;
  334. prWifiCmd->ucSeqNum = prCmdInfo->ucCmdSeqNum;
  335. if (u4SetQueryInfoLen > 0 && pucInfoBuffer != NULL)
  336. kalMemCopy(prWifiCmd->aucBuffer, pucInfoBuffer, u4SetQueryInfoLen);
  337. /* insert into prCmdQueue */
  338. kalEnqueueCommand(prGlueInfo, (P_QUE_ENTRY_T) prCmdInfo);
  339. /* wakeup txServiceThread later */
  340. GLUE_SET_EVENT(prGlueInfo);
  341. return WLAN_STATUS_PENDING;
  342. }
  343. /*----------------------------------------------------------------------------*/
  344. /*!
  345. * \brief This routine is called to set a key to Wi-Fi Direct driver
  346. *
  347. * \param[in] prAdapter Pointer to the Adapter structure.
  348. * \param[in] pvSetBuffer A pointer to the buffer that holds the data to be set.
  349. * \param[in] u4SetBufferLen The length of the set buffer.
  350. * \param[out] pu4SetInfoLen If the call is successful, returns the number of
  351. * bytes read from the set buffer. If the call failed
  352. * due to invalid length of the set buffer, returns
  353. * the amount of storage needed.
  354. *
  355. * \retval WLAN_STATUS_SUCCESS
  356. * \retval WLAN_STATUS_ADAPTER_NOT_READY
  357. * \retval WLAN_STATUS_INVALID_LENGTH
  358. * \retval WLAN_STATUS_INVALID_DATA
  359. */
  360. /*----------------------------------------------------------------------------*/
  361. WLAN_STATUS
  362. wlanoidSetAddP2PKey(IN P_ADAPTER_T prAdapter,
  363. IN PVOID pvSetBuffer, IN UINT_32 u4SetBufferLen, OUT PUINT_32 pu4SetInfoLen)
  364. {
  365. CMD_802_11_KEY rCmdKey;
  366. P_PARAM_KEY_T prNewKey;
  367. P_BSS_INFO_T prBssInfo = (P_BSS_INFO_T) NULL;
  368. P_STA_RECORD_T prStaRec = (P_STA_RECORD_T) NULL;
  369. DEBUGFUNC("wlanoidSetAddP2PKey");
  370. DBGLOG(REQ, INFO, "\n");
  371. ASSERT(prAdapter);
  372. ASSERT(pvSetBuffer);
  373. ASSERT(pu4SetInfoLen);
  374. prNewKey = (P_PARAM_KEY_T) pvSetBuffer;
  375. /* Verify the key structure length. */
  376. if (prNewKey->u4Length > u4SetBufferLen) {
  377. DBGLOG(REQ, WARN,
  378. "Invalid key structure length (%d) greater than total buffer length (%d)\n",
  379. (UINT_8) prNewKey->u4Length, (UINT_8) u4SetBufferLen);
  380. *pu4SetInfoLen = u4SetBufferLen;
  381. return WLAN_STATUS_INVALID_LENGTH;
  382. }
  383. /* Verify the key material length for key material buffer */
  384. else if (prNewKey->u4KeyLength > prNewKey->u4Length - OFFSET_OF(PARAM_KEY_T, aucKeyMaterial)) {
  385. DBGLOG(REQ, WARN, "Invalid key material length (%d)\n", (UINT_8) prNewKey->u4KeyLength);
  386. *pu4SetInfoLen = u4SetBufferLen;
  387. return WLAN_STATUS_INVALID_DATA;
  388. }
  389. /* Exception check */
  390. else if (prNewKey->u4KeyIndex & 0x0fffff00)
  391. return WLAN_STATUS_INVALID_DATA;
  392. /* Exception check, pairwise key must with transmit bit enabled */
  393. else if ((prNewKey->u4KeyIndex & BITS(30, 31)) == IS_UNICAST_KEY) {
  394. return WLAN_STATUS_INVALID_DATA;
  395. } else if (!(prNewKey->u4KeyLength == CCMP_KEY_LEN)
  396. && !(prNewKey->u4KeyLength == TKIP_KEY_LEN)) {
  397. return WLAN_STATUS_INVALID_DATA;
  398. }
  399. /* Exception check, pairwise key must with transmit bit enabled */
  400. else if ((prNewKey->u4KeyIndex & BITS(30, 31)) == BITS(30, 31)) {
  401. if (((prNewKey->u4KeyIndex & 0xff) != 0) ||
  402. ((prNewKey->arBSSID[0] == 0xff) && (prNewKey->arBSSID[1] == 0xff)
  403. && (prNewKey->arBSSID[2] == 0xff) && (prNewKey->arBSSID[3] == 0xff)
  404. && (prNewKey->arBSSID[4] == 0xff) && (prNewKey->arBSSID[5] == 0xff))) {
  405. return WLAN_STATUS_INVALID_DATA;
  406. }
  407. }
  408. *pu4SetInfoLen = u4SetBufferLen;
  409. prBssInfo = GET_BSS_INFO_BY_INDEX(prAdapter, prNewKey->ucBssIdx);
  410. ASSERT(prBssInfo);
  411. if (prBssInfo->ucBMCWlanIndex >= WTBL_SIZE) {
  412. prBssInfo->ucBMCWlanIndex =
  413. secPrivacySeekForBcEntry(prAdapter, prBssInfo->ucBssIndex, prBssInfo->aucBSSID,
  414. 0xff, CIPHER_SUITE_NONE, 0xff, 0x0, BIT(0));
  415. }
  416. /* fill CMD_802_11_KEY */
  417. kalMemZero(&rCmdKey, sizeof(CMD_802_11_KEY));
  418. rCmdKey.ucAddRemove = 1; /* add */
  419. rCmdKey.ucTxKey = ((prNewKey->u4KeyIndex & IS_TRANSMIT_KEY) == IS_TRANSMIT_KEY) ? 1 : 0;
  420. rCmdKey.ucKeyType = ((prNewKey->u4KeyIndex & IS_UNICAST_KEY) == IS_UNICAST_KEY) ? 1 : 0;
  421. #if 0
  422. if (prBssInfo->eCurrentOPMode == OP_MODE_INFRASTRUCTURE) { /* group client */
  423. #else
  424. if (kalP2PGetRole(prAdapter->prGlueInfo) == 1) { /* group client */
  425. #endif
  426. rCmdKey.ucIsAuthenticator = 0;
  427. } else { /* group owner */
  428. rCmdKey.ucIsAuthenticator = 1;
  429. /* Force to set GO/AP Tx */
  430. rCmdKey.ucTxKey = 1;
  431. }
  432. COPY_MAC_ADDR(rCmdKey.aucPeerAddr, prNewKey->arBSSID);
  433. rCmdKey.ucBssIdx = prNewKey->ucBssIdx;
  434. if (prNewKey->u4KeyLength == CCMP_KEY_LEN)
  435. rCmdKey.ucAlgorithmId = CIPHER_SUITE_CCMP; /* AES */
  436. else if (prNewKey->u4KeyLength == TKIP_KEY_LEN)
  437. rCmdKey.ucAlgorithmId = CIPHER_SUITE_TKIP; /* TKIP */
  438. else if (prNewKey->u4KeyLength == WEP_40_LEN)
  439. rCmdKey.ucAlgorithmId = CIPHER_SUITE_WEP40; /* WEP 40 */
  440. else if (prNewKey->u4KeyLength == WEP_104_LEN)
  441. rCmdKey.ucAlgorithmId = CIPHER_SUITE_WEP104; /* WEP 104 */
  442. else
  443. ASSERT(FALSE);
  444. rCmdKey.ucKeyId = (UINT_8) (prNewKey->u4KeyIndex & 0xff);
  445. rCmdKey.ucKeyLen = (UINT_8) prNewKey->u4KeyLength;
  446. kalMemCopy(rCmdKey.aucKeyMaterial, (PUINT_8) prNewKey->aucKeyMaterial, rCmdKey.ucKeyLen);
  447. if ((rCmdKey.aucPeerAddr[0] & rCmdKey.aucPeerAddr[1] & rCmdKey.aucPeerAddr[2] &
  448. rCmdKey.aucPeerAddr[3] & rCmdKey.aucPeerAddr[4] & rCmdKey.aucPeerAddr[5]) == 0xFF) {
  449. kalMemCopy(rCmdKey.aucPeerAddr, prBssInfo->aucBSSID, MAC_ADDR_LEN);
  450. if (!rCmdKey.ucIsAuthenticator) {
  451. prStaRec = cnmGetStaRecByAddress(prAdapter, rCmdKey.ucBssIdx, rCmdKey.aucPeerAddr);
  452. if (!prStaRec)
  453. ASSERT(FALSE);
  454. }
  455. } else {
  456. prStaRec = cnmGetStaRecByAddress(prAdapter, rCmdKey.ucBssIdx, rCmdKey.aucPeerAddr);
  457. }
  458. if (rCmdKey.ucTxKey) {
  459. if (prStaRec) {
  460. if (rCmdKey.ucKeyType) { /* RSN STA */
  461. ASSERT(prStaRec->ucWlanIndex < WTBL_SIZE);
  462. rCmdKey.ucWlanIndex = prStaRec->ucWlanIndex;
  463. prStaRec->fgTransmitKeyExist = TRUE; /* wait for CMD Done ? */
  464. } else {
  465. ASSERT(FALSE);
  466. /* prCmdKey->ucWlanIndex = secPrivacySeekForBcEntry(prAdapter, prBssInfo->ucBssIndex, */
  467. /* NETWORK_TYPE_AIS, prCmdKey->aucPeerAddr,*/
  468. /* prCmdKey->ucAlgorithmId, prCmdKey->ucKeyId, */
  469. /* prStaRec->ucCurrentGtkId, BIT(1)); */
  470. /* Todo:: Check the prCmdKey->ucKeyType */
  471. /* for some case, like wep, add bc wep key before sta create,*/
  472. /* so use the rAisSpecificBssInfo to save key setting */
  473. /* fgAddTxBcKey = TRUE; */
  474. }
  475. } else {
  476. if (prBssInfo) { /* GO/AP Tx BC */
  477. ASSERT(prBssInfo->ucBMCWlanIndex < WTBL_SIZE);
  478. rCmdKey.ucWlanIndex = prBssInfo->ucBMCWlanIndex;
  479. /* rCmdKey.ucWlanIndex = secPrivacySeekForBcEntry(prAdapter, prBssInfo->ucBssIndex, */
  480. /* prBssInfo->aucBSSID, 0xff, rCmdKey.ucAlgorithmId, rCmdKey.ucKeyId, */
  481. /* prBssInfo->ucCurrentGtkId, BIT(1)); */
  482. prBssInfo->fgTxBcKeyExist = TRUE;
  483. prBssInfo->ucTxDefaultKeyID = rCmdKey.ucKeyId;
  484. } else {
  485. rCmdKey.ucWlanIndex = 255; /* GC WEP Tx key ? */
  486. ASSERT(FALSE);
  487. }
  488. }
  489. } else {
  490. if (((rCmdKey.aucPeerAddr[0] & rCmdKey.aucPeerAddr[1] & rCmdKey.aucPeerAddr[2] &
  491. rCmdKey.aucPeerAddr[3] & rCmdKey.aucPeerAddr[4] & rCmdKey.aucPeerAddr[5]) == 0xFF)
  492. ||
  493. ((rCmdKey.aucPeerAddr[0] | rCmdKey.aucPeerAddr[1] | rCmdKey.
  494. aucPeerAddr[2] | rCmdKey.aucPeerAddr[3] | rCmdKey.aucPeerAddr[4] | rCmdKey.aucPeerAddr[5]) ==
  495. 0x00)) {
  496. rCmdKey.ucWlanIndex = 255; /* GC WEP ? */
  497. ASSERT(FALSE);
  498. } else {
  499. if (prStaRec) { /* GC Rx RSN Group key */
  500. rCmdKey.ucWlanIndex =
  501. secPrivacySeekForBcEntry(prAdapter, prStaRec->ucBssIndex,
  502. prStaRec->aucMacAddr,
  503. prStaRec->ucIndex,
  504. rCmdKey.ucAlgorithmId, rCmdKey.ucKeyId,
  505. prStaRec->ucCurrentGtkId, BIT(0));
  506. prStaRec->ucBMCWlanIndex = rCmdKey.ucWlanIndex;
  507. ASSERT(prStaRec->ucBMCWlanIndex < WTBL_SIZE);
  508. } else { /* Exist this case ? */
  509. ASSERT(FALSE);
  510. /* prCmdKey->ucWlanIndex = */
  511. /* secPrivacySeekForBcEntry(prAdapter, */
  512. /* prBssInfo->ucBssIndex, */
  513. /* NETWORK_TYPE_AIS, */
  514. /* prCmdKey->aucPeerAddr, */
  515. /* prCmdKey->ucAlgorithmId, */
  516. /* prCmdKey->ucKeyId, */
  517. /* prBssInfo->ucCurrentGtkId, */
  518. /* BIT(0)); */
  519. }
  520. }
  521. }
  522. /* Update Group Key Id after Seek Bc entry */
  523. if (!rCmdKey.ucKeyType) {
  524. if (prStaRec)
  525. prStaRec->ucCurrentGtkId = rCmdKey.ucKeyId;
  526. else {
  527. /* GC WEP? */
  528. prBssInfo->ucCurrentGtkId = rCmdKey.ucKeyId;
  529. }
  530. }
  531. return wlanoidSendSetQueryP2PCmd(prAdapter,
  532. CMD_ID_ADD_REMOVE_KEY,
  533. prNewKey->ucBssIdx,
  534. TRUE,
  535. FALSE,
  536. TRUE,
  537. nicCmdEventSetCommon,
  538. NULL,
  539. sizeof(CMD_802_11_KEY), (PUINT_8)&rCmdKey, pvSetBuffer, u4SetBufferLen);
  540. }
  541. /*----------------------------------------------------------------------------*/
  542. /*!
  543. * \brief This routine is called to request Wi-Fi Direct driver to remove keys
  544. *
  545. * \param[in] prAdapter Pointer to the Adapter structure.
  546. * \param[in] pvSetBuffer A pointer to the buffer that holds the data to be set.
  547. * \param[in] u4SetBufferLen The length of the set buffer.
  548. * \param[out] pu4SetInfoLen If the call is successful, returns the number of
  549. * bytes read from the set buffer. If the call failed
  550. * due to invalid length of the set buffer, returns
  551. * the amount of storage needed.
  552. *
  553. * \retval WLAN_STATUS_SUCCESS
  554. * \retval WLAN_STATUS_INVALID_DATA
  555. * \retval WLAN_STATUS_INVALID_LENGTH
  556. * \retval WLAN_STATUS_INVALID_DATA
  557. */
  558. /*----------------------------------------------------------------------------*/
  559. WLAN_STATUS
  560. wlanoidSetRemoveP2PKey(IN P_ADAPTER_T prAdapter,
  561. IN PVOID pvSetBuffer, IN UINT_32 u4SetBufferLen, OUT PUINT_32 pu4SetInfoLen)
  562. {
  563. CMD_802_11_KEY rCmdKey;
  564. P_PARAM_REMOVE_KEY_T prRemovedKey;
  565. P_BSS_INFO_T prBssInfo = (P_BSS_INFO_T) NULL;
  566. P_STA_RECORD_T prStaRec = (P_STA_RECORD_T) NULL;
  567. DEBUGFUNC("wlanoidSetRemoveP2PKey");
  568. ASSERT(prAdapter);
  569. if (u4SetBufferLen < sizeof(PARAM_REMOVE_KEY_T))
  570. return WLAN_STATUS_INVALID_LENGTH;
  571. ASSERT(pvSetBuffer);
  572. prRemovedKey = (P_PARAM_REMOVE_KEY_T) pvSetBuffer;
  573. /* Check bit 31: this bit should always 0 */
  574. if (prRemovedKey->u4KeyIndex & IS_TRANSMIT_KEY) {
  575. /* Bit 31 should not be set */
  576. DBGLOG(REQ, ERROR, "invalid key index: 0x%08lx\n", prRemovedKey->u4KeyIndex);
  577. return WLAN_STATUS_INVALID_DATA;
  578. }
  579. /* Check bits 8 ~ 29 should always be 0 */
  580. if (prRemovedKey->u4KeyIndex & BITS(8, 29)) {
  581. /* Bit 31 should not be set */
  582. DBGLOG(REQ, ERROR, "invalid key index: 0x%08lx\n", prRemovedKey->u4KeyIndex);
  583. return WLAN_STATUS_INVALID_DATA;
  584. }
  585. prBssInfo = GET_BSS_INFO_BY_INDEX(prAdapter, prRemovedKey->ucBssIdx);
  586. kalMemZero((PUINT_8)&rCmdKey, sizeof(CMD_802_11_KEY));
  587. rCmdKey.ucAddRemove = 0; /* remove */
  588. if (prBssInfo->eCurrentOPMode == OP_MODE_INFRASTRUCTURE) { /* group client */
  589. rCmdKey.ucIsAuthenticator = 0;
  590. } else { /* group owner */
  591. rCmdKey.ucIsAuthenticator = 1;
  592. }
  593. kalMemCopy(rCmdKey.aucPeerAddr, (PUINT_8) prRemovedKey->arBSSID, MAC_ADDR_LEN);
  594. rCmdKey.ucBssIdx = prRemovedKey->ucBssIdx;
  595. rCmdKey.ucKeyId = (UINT_8) (prRemovedKey->u4KeyIndex & 0x000000ff);
  596. /* Clean up the Tx key flag */
  597. prStaRec = cnmGetStaRecByAddress(prAdapter, prRemovedKey->ucBssIdx, prRemovedKey->arBSSID);
  598. /* mark for MR1 to avoid remove-key, but remove the wlan_tbl0 at the same time */
  599. if (1/*prRemovedKey->u4KeyIndex & IS_UNICAST_KEY */) {
  600. if (prStaRec) {
  601. rCmdKey.ucKeyType = 1;
  602. rCmdKey.ucWlanIndex = prStaRec->ucWlanIndex;
  603. prStaRec->fgTransmitKeyExist = FALSE;
  604. } else if (rCmdKey.ucIsAuthenticator)
  605. prBssInfo->fgTxBcKeyExist = FALSE;
  606. } else {
  607. if (rCmdKey.ucIsAuthenticator)
  608. prBssInfo->fgTxBcKeyExist = FALSE;
  609. }
  610. if (!prStaRec) {
  611. if (prAdapter->rWifiVar.rConnSettings.eAuthMode < AUTH_MODE_WPA
  612. && prAdapter->rWifiVar.rConnSettings.eEncStatus != ENUM_ENCRYPTION_DISABLED) {
  613. rCmdKey.ucWlanIndex = prBssInfo->ucBMCWlanIndex;
  614. } else {
  615. rCmdKey.ucWlanIndex = WTBL_RESERVED_ENTRY;
  616. return WLAN_STATUS_SUCCESS;
  617. }
  618. }
  619. /* mark for MR1 to avoid remove-key, but remove the wlan_tbl0 at the same time */
  620. /* secPrivacyFreeForEntry(prAdapter, rCmdKey.ucWlanIndex); */
  621. return wlanoidSendSetQueryP2PCmd(prAdapter,
  622. CMD_ID_ADD_REMOVE_KEY,
  623. prRemovedKey->ucBssIdx,
  624. TRUE,
  625. FALSE,
  626. TRUE,
  627. nicCmdEventSetCommon,
  628. NULL,
  629. sizeof(CMD_802_11_KEY), (PUINT_8)&rCmdKey, pvSetBuffer, u4SetBufferLen);
  630. }
  631. /*----------------------------------------------------------------------------*/
  632. /*!
  633. * \brief Setting the IP address for pattern search function.
  634. *
  635. * \param[in] prAdapter Pointer to the Adapter structure.
  636. * \param[in] pvSetBuffer A pointer to the buffer that holds the data to be set.
  637. * \param[in] u4SetBufferLen The length of the set buffer.
  638. * \param[out] pu4SetInfoLen If the call is successful, returns the number of
  639. * bytes read from the set buffer. If the call failed
  640. * due to invalid length of the set buffer, returns
  641. * the amount of storage needed.
  642. *
  643. * \return WLAN_STATUS_SUCCESS
  644. * \return WLAN_STATUS_ADAPTER_NOT_READY
  645. * \return WLAN_STATUS_INVALID_LENGTH
  646. */
  647. /*----------------------------------------------------------------------------*/
  648. WLAN_STATUS
  649. wlanoidSetP2pNetworkAddress(IN P_ADAPTER_T prAdapter,
  650. IN PVOID pvSetBuffer, IN UINT_32 u4SetBufferLen, OUT PUINT_32 pu4SetInfoLen)
  651. {
  652. WLAN_STATUS rStatus = WLAN_STATUS_SUCCESS;
  653. UINT_32 i, j;
  654. P_CMD_SET_NETWORK_ADDRESS_LIST prCmdNetworkAddressList;
  655. P_PARAM_NETWORK_ADDRESS_LIST prNetworkAddressList = (P_PARAM_NETWORK_ADDRESS_LIST) pvSetBuffer;
  656. P_PARAM_NETWORK_ADDRESS prNetworkAddress;
  657. P_PARAM_NETWORK_ADDRESS_IP prNetAddrIp;
  658. UINT_32 u4IpAddressCount, u4CmdSize;
  659. DEBUGFUNC("wlanoidSetP2pNetworkAddress");
  660. DBGLOG(INIT, TRACE, "\n");
  661. ASSERT(prAdapter);
  662. ASSERT(pu4SetInfoLen);
  663. *pu4SetInfoLen = 4;
  664. if (u4SetBufferLen < sizeof(PARAM_NETWORK_ADDRESS_LIST))
  665. return WLAN_STATUS_INVALID_DATA;
  666. *pu4SetInfoLen = 0;
  667. u4IpAddressCount = 0;
  668. prNetworkAddress = prNetworkAddressList->arAddress;
  669. for (i = 0; i < prNetworkAddressList->u4AddressCount; i++) {
  670. if (prNetworkAddress->u2AddressType == PARAM_PROTOCOL_ID_TCP_IP &&
  671. prNetworkAddress->u2AddressLength == sizeof(PARAM_NETWORK_ADDRESS_IP)) {
  672. u4IpAddressCount++;
  673. }
  674. prNetworkAddress = (P_PARAM_NETWORK_ADDRESS) ((ULONG) prNetworkAddress +
  675. (ULONG) (prNetworkAddress->u2AddressLength +
  676. OFFSET_OF(PARAM_NETWORK_ADDRESS, aucAddress)));
  677. }
  678. /* construct payload of command packet */
  679. u4CmdSize = OFFSET_OF(CMD_SET_NETWORK_ADDRESS_LIST, arNetAddress) +
  680. sizeof(IPV4_NETWORK_ADDRESS) * u4IpAddressCount;
  681. prCmdNetworkAddressList = (P_CMD_SET_NETWORK_ADDRESS_LIST) kalMemAlloc(u4CmdSize, VIR_MEM_TYPE);
  682. if (prCmdNetworkAddressList == NULL)
  683. return WLAN_STATUS_FAILURE;
  684. /* fill P_CMD_SET_NETWORK_ADDRESS_LIST */
  685. prCmdNetworkAddressList->ucBssIndex = prNetworkAddressList->ucBssIdx;
  686. prCmdNetworkAddressList->ucAddressCount = (UINT_8) u4IpAddressCount;
  687. prNetworkAddress = prNetworkAddressList->arAddress;
  688. for (i = 0, j = 0; i < prNetworkAddressList->u4AddressCount; i++) {
  689. if (prNetworkAddress->u2AddressType == PARAM_PROTOCOL_ID_TCP_IP &&
  690. prNetworkAddress->u2AddressLength == sizeof(PARAM_NETWORK_ADDRESS_IP)) {
  691. prNetAddrIp = (P_PARAM_NETWORK_ADDRESS_IP) prNetworkAddress->aucAddress;
  692. kalMemCopy(prCmdNetworkAddressList->arNetAddress[j].aucIpAddr,
  693. &(prNetAddrIp->in_addr), sizeof(UINT_32));
  694. j++;
  695. }
  696. prNetworkAddress = (P_PARAM_NETWORK_ADDRESS) ((ULONG) prNetworkAddress +
  697. (ULONG) (prNetworkAddress->u2AddressLength +
  698. OFFSET_OF(PARAM_NETWORK_ADDRESS, aucAddress)));
  699. }
  700. rStatus = wlanSendSetQueryCmd(prAdapter,
  701. CMD_ID_SET_IP_ADDRESS,
  702. TRUE,
  703. FALSE,
  704. TRUE,
  705. nicCmdEventSetIpAddress,
  706. nicOidCmdTimeoutCommon,
  707. u4CmdSize, (PUINT_8) prCmdNetworkAddressList, pvSetBuffer, u4SetBufferLen);
  708. kalMemFree(prCmdNetworkAddressList, VIR_MEM_TYPE, u4CmdSize);
  709. return rStatus;
  710. }
  711. /*----------------------------------------------------------------------------*/
  712. /*!
  713. * \brief This routine is used to query the power save profile.
  714. *
  715. * \param[in] prAdapter Pointer to the Adapter structure.
  716. * \param[out] pvQueryBuf A pointer to the buffer that holds the result of
  717. * the query.
  718. * \param[in] u4QueryBufLen The length of the query buffer.
  719. * \param[out] pu4QueryInfoLen If the call is successful, returns the number of
  720. * bytes written into the query buffer. If the call
  721. * failed due to invalid length of the query buffer,
  722. * returns the amount of storage needed.
  723. *
  724. * \return WLAN_STATUS_SUCCESS
  725. */
  726. /*----------------------------------------------------------------------------*/
  727. WLAN_STATUS
  728. wlanoidQueryP2pPowerSaveProfile(IN P_ADAPTER_T prAdapter,
  729. IN PVOID pvQueryBuffer, IN UINT_32 u4QueryBufferLen, OUT PUINT_32 pu4QueryInfoLen)
  730. {
  731. DEBUGFUNC("wlanoidQueryP2pPowerSaveProfile");
  732. ASSERT(prAdapter);
  733. ASSERT(pu4QueryInfoLen);
  734. if (u4QueryBufferLen != 0) {
  735. ASSERT(pvQueryBuffer);
  736. /* TODO: FIXME */
  737. /* *(PPARAM_POWER_MODE) pvQueryBuffer =
  738. * (PARAM_POWER_MODE)(prAdapter->rWlanInfo.arPowerSaveMode[P2P_DEV_BSS_INDEX].ucPsProfile); */
  739. /* *pu4QueryInfoLen = sizeof(PARAM_POWER_MODE); */
  740. }
  741. return WLAN_STATUS_SUCCESS;
  742. }
  743. /*----------------------------------------------------------------------------*/
  744. /*!
  745. * \brief This routine is used to set the power save profile.
  746. *
  747. * \param[in] pvAdapter Pointer to the Adapter structure.
  748. * \param[in] pvSetBuffer A pointer to the buffer that holds the data to be set.
  749. * \param[in] u4SetBufferLen The length of the set buffer.
  750. * \param[out] pu4SetInfoLen If the call is successful, returns the number of
  751. * bytes read from the set buffer. If the call failed
  752. * due to invalid length of the set buffer, returns
  753. * the amount of storage needed.
  754. *
  755. * \retval WLAN_STATUS_SUCCESS
  756. * \retval WLAN_STATUS_INVALID_LENGTH
  757. */
  758. /*----------------------------------------------------------------------------*/
  759. WLAN_STATUS
  760. wlanoidSetP2pPowerSaveProfile(IN P_ADAPTER_T prAdapter,
  761. IN PVOID pvSetBuffer, IN UINT_32 u4SetBufferLen, OUT PUINT_32 pu4SetInfoLen)
  762. {
  763. WLAN_STATUS status;
  764. PARAM_POWER_MODE ePowerMode;
  765. DEBUGFUNC("wlanoidSetP2pPowerSaveProfile");
  766. ASSERT(prAdapter);
  767. ASSERT(pu4SetInfoLen);
  768. *pu4SetInfoLen = sizeof(PARAM_POWER_MODE);
  769. if (u4SetBufferLen < sizeof(PARAM_POWER_MODE)) {
  770. DBGLOG(REQ, WARN, "Invalid length %ld\n", u4SetBufferLen);
  771. return WLAN_STATUS_INVALID_LENGTH;
  772. } else if (*(PPARAM_POWER_MODE) pvSetBuffer >= Param_PowerModeMax) {
  773. DBGLOG(REQ, WARN, "Invalid power mode %d\n", *(PPARAM_POWER_MODE) pvSetBuffer);
  774. return WLAN_STATUS_INVALID_DATA;
  775. }
  776. ePowerMode = *(PPARAM_POWER_MODE) pvSetBuffer;
  777. if (prAdapter->fgEnCtiaPowerMode) {
  778. if (ePowerMode == Param_PowerModeCAM) {
  779. /*Todo:: Nothing*/
  780. /*Todo:: Nothing*/
  781. } else {
  782. /* User setting to PS mode (Param_PowerModeMAX_PSP or Param_PowerModeFast_PSP) */
  783. if (prAdapter->u4CtiaPowerMode == 0) {
  784. /* force to keep in CAM mode */
  785. ePowerMode = Param_PowerModeCAM;
  786. } else if (prAdapter->u4CtiaPowerMode == 1) {
  787. ePowerMode = Param_PowerModeMAX_PSP;
  788. } else if (prAdapter->u4CtiaPowerMode == 2) {
  789. ePowerMode = Param_PowerModeFast_PSP;
  790. }
  791. }
  792. }
  793. status = nicConfigPowerSaveProfile(prAdapter, P2P_DEV_BSS_INDEX, /* TODO: FIXME */
  794. ePowerMode, TRUE);
  795. return status;
  796. } /* end of wlanoidSetP2pPowerSaveProfile() */
  797. /*----------------------------------------------------------------------------*/
  798. /*!
  799. * \brief This routine is used to set the power save profile.
  800. *
  801. * \param[in] pvAdapter Pointer to the Adapter structure.
  802. * \param[in] pvSetBuffer A pointer to the buffer that holds the data to be set.
  803. * \param[in] u4SetBufferLen The length of the set buffer.
  804. * \param[out] pu4SetInfoLen If the call is successful, returns the number of
  805. * bytes read from the set buffer. If the call failed
  806. * due to invalid length of the set buffer, returns
  807. * the amount of storage needed.
  808. *
  809. * \retval WLAN_STATUS_SUCCESS
  810. * \retval WLAN_STATUS_INVALID_LENGTH
  811. */
  812. /*----------------------------------------------------------------------------*/
  813. WLAN_STATUS
  814. wlanoidSetP2pSetNetworkAddress(IN P_ADAPTER_T prAdapter,
  815. IN PVOID pvSetBuffer, IN UINT_32 u4SetBufferLen, OUT PUINT_32 pu4SetInfoLen)
  816. {
  817. WLAN_STATUS rStatus = WLAN_STATUS_SUCCESS;
  818. UINT_32 i, j;
  819. P_CMD_SET_NETWORK_ADDRESS_LIST prCmdNetworkAddressList;
  820. P_PARAM_NETWORK_ADDRESS_LIST prNetworkAddressList = (P_PARAM_NETWORK_ADDRESS_LIST) pvSetBuffer;
  821. P_PARAM_NETWORK_ADDRESS prNetworkAddress;
  822. P_PARAM_NETWORK_ADDRESS_IP prNetAddrIp;
  823. UINT_32 u4IpAddressCount, u4CmdSize;
  824. PUINT_8 pucBuf = (PUINT_8) pvSetBuffer;
  825. DEBUGFUNC("wlanoidSetP2pSetNetworkAddress");
  826. DBGLOG(INIT, TRACE, "\n");
  827. DBGLOG(INIT, INFO, "wlanoidSetP2pSetNetworkAddress (%d)\n", (INT_16) u4SetBufferLen);
  828. ASSERT(prAdapter);
  829. ASSERT(pu4SetInfoLen);
  830. *pu4SetInfoLen = 4;
  831. if (u4SetBufferLen < sizeof(PARAM_NETWORK_ADDRESS_LIST))
  832. return WLAN_STATUS_INVALID_DATA;
  833. *pu4SetInfoLen = 0;
  834. u4IpAddressCount = 0;
  835. prNetworkAddress = prNetworkAddressList->arAddress;
  836. for (i = 0; i < prNetworkAddressList->u4AddressCount; i++) {
  837. if (prNetworkAddress->u2AddressType == PARAM_PROTOCOL_ID_TCP_IP &&
  838. prNetworkAddress->u2AddressLength == sizeof(PARAM_NETWORK_ADDRESS_IP)) {
  839. u4IpAddressCount++;
  840. }
  841. prNetworkAddress = (P_PARAM_NETWORK_ADDRESS) ((ULONG) prNetworkAddress +
  842. (ULONG) (prNetworkAddress->u2AddressLength +
  843. OFFSET_OF(PARAM_NETWORK_ADDRESS, aucAddress)));
  844. }
  845. /* construct payload of command packet */
  846. u4CmdSize = OFFSET_OF(CMD_SET_NETWORK_ADDRESS_LIST, arNetAddress) +
  847. sizeof(IPV4_NETWORK_ADDRESS) * u4IpAddressCount;
  848. if (u4IpAddressCount == 0)
  849. u4CmdSize = sizeof(CMD_SET_NETWORK_ADDRESS_LIST);
  850. prCmdNetworkAddressList = (P_CMD_SET_NETWORK_ADDRESS_LIST) kalMemAlloc(u4CmdSize, VIR_MEM_TYPE);
  851. if (prCmdNetworkAddressList == NULL)
  852. return WLAN_STATUS_FAILURE;
  853. /* fill P_CMD_SET_NETWORK_ADDRESS_LIST */
  854. prCmdNetworkAddressList->ucBssIndex = prNetworkAddressList->ucBssIdx;
  855. /* only to set IP address to FW once ARP filter is enabled */
  856. if (prAdapter->fgEnArpFilter) {
  857. prCmdNetworkAddressList->ucAddressCount = (UINT_8) u4IpAddressCount;
  858. prNetworkAddress = prNetworkAddressList->arAddress;
  859. DBGLOG(INIT, INFO, "u4IpAddressCount (%ld)\n", (INT_32) u4IpAddressCount);
  860. for (i = 0, j = 0; i < prNetworkAddressList->u4AddressCount; i++) {
  861. if (prNetworkAddress->u2AddressType == PARAM_PROTOCOL_ID_TCP_IP &&
  862. prNetworkAddress->u2AddressLength == sizeof(PARAM_NETWORK_ADDRESS_IP)) {
  863. prNetAddrIp = (P_PARAM_NETWORK_ADDRESS_IP) prNetworkAddress->aucAddress;
  864. kalMemCopy(prCmdNetworkAddressList->arNetAddress[j].aucIpAddr,
  865. &(prNetAddrIp->in_addr), sizeof(UINT_32));
  866. j++;
  867. pucBuf = (PUINT_8) &prNetAddrIp->in_addr;
  868. DBGLOG(INIT, INFO, "prNetAddrIp->in_addr:%d:%d:%d:%d\n",
  869. (UINT_8) pucBuf[0], (UINT_8) pucBuf[1],
  870. (UINT_8) pucBuf[2], (UINT_8) pucBuf[3]);
  871. }
  872. prNetworkAddress = (P_PARAM_NETWORK_ADDRESS) ((ULONG) prNetworkAddress +
  873. (ULONG) (prNetworkAddress->u2AddressLength +
  874. OFFSET_OF
  875. (PARAM_NETWORK_ADDRESS, aucAddress)));
  876. }
  877. } else {
  878. prCmdNetworkAddressList->ucAddressCount = 0;
  879. }
  880. rStatus = wlanSendSetQueryCmd(prAdapter,
  881. CMD_ID_SET_IP_ADDRESS,
  882. TRUE,
  883. FALSE,
  884. TRUE,
  885. nicCmdEventSetIpAddress,
  886. nicOidCmdTimeoutCommon,
  887. u4CmdSize, (PUINT_8) prCmdNetworkAddressList, pvSetBuffer, u4SetBufferLen);
  888. kalMemFree(prCmdNetworkAddressList, VIR_MEM_TYPE, u4CmdSize);
  889. return rStatus;
  890. } /* end of wlanoidSetP2pSetNetworkAddress() */
  891. /*----------------------------------------------------------------------------*/
  892. /*!
  893. * \brief This routine is called to set Multicast Address List.
  894. *
  895. * \param[in] prAdapter Pointer to the Adapter structure.
  896. * \param[in] pvSetBuffer Pointer to the buffer that holds the data to be set.
  897. * \param[in] u4SetBufferLen The length of the set buffer.
  898. * \param[out] pu4SetInfoLen If the call is successful, returns the number of
  899. * bytes read from the set buffer. If the call failed
  900. * due to invalid length of the set buffer, returns
  901. * the amount of storage needed.
  902. *
  903. * \retval WLAN_STATUS_SUCCESS
  904. * \retval WLAN_STATUS_INVALID_LENGTH
  905. * \retval WLAN_STATUS_ADAPTER_NOT_READY
  906. * \retval WLAN_STATUS_MULTICAST_FULL
  907. */
  908. /*----------------------------------------------------------------------------*/
  909. WLAN_STATUS
  910. wlanoidSetP2PMulticastList(IN P_ADAPTER_T prAdapter,
  911. IN PVOID pvSetBuffer, IN UINT_32 u4SetBufferLen, OUT PUINT_32 pu4SetInfoLen)
  912. {
  913. CMD_MAC_MCAST_ADDR rCmdMacMcastAddr;
  914. ASSERT(prAdapter);
  915. ASSERT(pu4SetInfoLen);
  916. /* The data must be a multiple of the Ethernet address size. */
  917. if ((u4SetBufferLen % MAC_ADDR_LEN)) {
  918. DBGLOG(REQ, WARN, "Invalid MC list length %ld\n", u4SetBufferLen);
  919. *pu4SetInfoLen = (((u4SetBufferLen + MAC_ADDR_LEN) - 1) / MAC_ADDR_LEN) * MAC_ADDR_LEN;
  920. return WLAN_STATUS_INVALID_LENGTH;
  921. }
  922. *pu4SetInfoLen = u4SetBufferLen;
  923. /* Verify if we can support so many multicast addresses. */
  924. if ((u4SetBufferLen / MAC_ADDR_LEN) > MAX_NUM_GROUP_ADDR) {
  925. DBGLOG(REQ, WARN, "Too many MC addresses\n");
  926. return WLAN_STATUS_MULTICAST_FULL;
  927. }
  928. /* NOTE(Kevin): Windows may set u4SetBufferLen == 0 &&
  929. * pvSetBuffer == NULL to clear exist Multicast List.
  930. */
  931. if (u4SetBufferLen)
  932. ASSERT(pvSetBuffer);
  933. if (prAdapter->rAcpiState == ACPI_STATE_D3) {
  934. DBGLOG(REQ, WARN,
  935. "Fail in set multicast list! (Adapter not ready). ACPI=D%d, Radio=%d\n",
  936. prAdapter->rAcpiState, prAdapter->fgIsRadioOff);
  937. return WLAN_STATUS_ADAPTER_NOT_READY;
  938. }
  939. rCmdMacMcastAddr.u4NumOfGroupAddr = u4SetBufferLen / MAC_ADDR_LEN;
  940. rCmdMacMcastAddr.ucBssIndex = P2P_DEV_BSS_INDEX; /* TODO: */
  941. kalMemCopy(rCmdMacMcastAddr.arAddress, pvSetBuffer, u4SetBufferLen);
  942. return wlanoidSendSetQueryP2PCmd(prAdapter, CMD_ID_MAC_MCAST_ADDR, P2P_DEV_BSS_INDEX, /* TODO: */
  943. /* This CMD response is no need to complete the OID. Or the event would unsync. */
  944. TRUE, FALSE, FALSE,
  945. nicCmdEventSetCommon,
  946. nicOidCmdTimeoutCommon,
  947. sizeof(CMD_MAC_MCAST_ADDR),
  948. (PUINT_8) &rCmdMacMcastAddr, pvSetBuffer, u4SetBufferLen);
  949. } /* end of wlanoidSetP2PMulticastList() */
  950. /*----------------------------------------------------------------------------*/
  951. /*!
  952. * \brief This routine is called to send GAS frame for P2P Service Discovery Request
  953. *
  954. * \param[in] prAdapter Pointer to the Adapter structure.
  955. * \param[in] pvSetBuffer Pointer to the buffer that holds the data to be set.
  956. * \param[in] u4SetBufferLen The length of the set buffer.
  957. * \param[out] pu4SetInfoLen If the call is successful, returns the number of
  958. * bytes read from the set buffer. If the call failed
  959. * due to invalid length of the set buffer, returns
  960. * the amount of storage needed.
  961. *
  962. * \retval WLAN_STATUS_SUCCESS
  963. * \retval WLAN_STATUS_INVALID_LENGTH
  964. * \retval WLAN_STATUS_ADAPTER_NOT_READY
  965. * \retval WLAN_STATUS_MULTICAST_FULL
  966. */
  967. /*----------------------------------------------------------------------------*/
  968. WLAN_STATUS
  969. wlanoidSendP2PSDRequest(IN P_ADAPTER_T prAdapter,
  970. IN PVOID pvSetBuffer, IN UINT_32 u4SetBufferLen, OUT PUINT_32 pu4SetInfoLen)
  971. {
  972. WLAN_STATUS rWlanStatus = WLAN_STATUS_SUCCESS;
  973. ASSERT(prAdapter);
  974. ASSERT(pu4SetInfoLen);
  975. if (u4SetBufferLen)
  976. ASSERT(pvSetBuffer);
  977. if (u4SetBufferLen < sizeof(PARAM_P2P_SEND_SD_REQUEST)) {
  978. *pu4SetInfoLen = sizeof(PARAM_P2P_SEND_SD_REQUEST);
  979. return WLAN_STATUS_BUFFER_TOO_SHORT;
  980. }
  981. /* rWlanStatus = p2pFsmRunEventSDRequest(prAdapter, (P_PARAM_P2P_SEND_SD_REQUEST)pvSetBuffer); */
  982. return rWlanStatus;
  983. } /* end of wlanoidSendP2PSDRequest() */
  984. /*----------------------------------------------------------------------------*/
  985. /*!
  986. * \brief This routine is called to send GAS frame for P2P Service Discovery Response
  987. *
  988. * \param[in] prAdapter Pointer to the Adapter structure.
  989. * \param[in] pvSetBuffer Pointer to the buffer that holds the data to be set.
  990. * \param[in] u4SetBufferLen The length of the set buffer.
  991. * \param[out] pu4SetInfoLen If the call is successful, returns the number of
  992. * bytes read from the set buffer. If the call failed
  993. * due to invalid length of the set buffer, returns
  994. * the amount of storage needed.
  995. *
  996. * \retval WLAN_STATUS_SUCCESS
  997. * \retval WLAN_STATUS_INVALID_LENGTH
  998. * \retval WLAN_STATUS_ADAPTER_NOT_READY
  999. * \retval WLAN_STATUS_MULTICAST_FULL
  1000. */
  1001. /*----------------------------------------------------------------------------*/
  1002. WLAN_STATUS
  1003. wlanoidSendP2PSDResponse(IN P_ADAPTER_T prAdapter,
  1004. IN PVOID pvSetBuffer, IN UINT_32 u4SetBufferLen, OUT PUINT_32 pu4SetInfoLen)
  1005. {
  1006. WLAN_STATUS rWlanStatus = WLAN_STATUS_SUCCESS;
  1007. ASSERT(prAdapter);
  1008. ASSERT(pu4SetInfoLen);
  1009. if (u4SetBufferLen)
  1010. ASSERT(pvSetBuffer);
  1011. if (u4SetBufferLen < sizeof(PARAM_P2P_SEND_SD_RESPONSE)) {
  1012. *pu4SetInfoLen = sizeof(PARAM_P2P_SEND_SD_RESPONSE);
  1013. return WLAN_STATUS_BUFFER_TOO_SHORT;
  1014. }
  1015. /* rWlanStatus = p2pFsmRunEventSDResponse(prAdapter, (P_PARAM_P2P_SEND_SD_RESPONSE)pvSetBuffer); */
  1016. return rWlanStatus;
  1017. } /* end of wlanoidGetP2PSDRequest() */
  1018. /*----------------------------------------------------------------------------*/
  1019. /*!
  1020. * \brief This routine is called to get GAS frame for P2P Service Discovery Request
  1021. *
  1022. * \param[in] prAdapter Pointer to the Adapter structure.
  1023. * \param[out] pvQueryBuffer A pointer to the buffer that holds the result of
  1024. * the query.
  1025. * \param[in] u4QueryBufferLen The length of the query buffer.
  1026. * \param[out] pu4QueryInfoLen If the call is successful, returns the number of
  1027. * bytes written into the query buffer. If the call
  1028. * failed due to invalid length of the query buffer,
  1029. * returns the amount of storage needed.
  1030. *
  1031. * \retval WLAN_STATUS_SUCCESS
  1032. * \retval WLAN_STATUS_INVALID_LENGTH
  1033. * \retval WLAN_STATUS_ADAPTER_NOT_READY
  1034. * \retval WLAN_STATUS_MULTICAST_FULL
  1035. */
  1036. /*----------------------------------------------------------------------------*/
  1037. WLAN_STATUS
  1038. wlanoidGetP2PSDRequest(IN P_ADAPTER_T prAdapter,
  1039. IN PVOID pvQueryBuffer, IN UINT_32 u4QueryBufferLen, OUT PUINT_32 pu4QueryInfoLen)
  1040. {
  1041. WLAN_STATUS rWlanStatus = WLAN_STATUS_SUCCESS;
  1042. PUINT_8 pucPacketBuffer = NULL, pucTA = NULL;
  1043. /* PUINT_8 pucChannelNum = NULL; */
  1044. PUINT_16 pu2PacketLength = NULL;
  1045. P_WLAN_MAC_HEADER_T prWlanHdr = (P_WLAN_MAC_HEADER_T) NULL;
  1046. UINT_8 ucVersionNum = 0;
  1047. /* UINT_8 ucChannelNum = 0, ucSeqNum = 0; */
  1048. ASSERT(prAdapter);
  1049. ASSERT(pu4QueryInfoLen);
  1050. if (u4QueryBufferLen)
  1051. ASSERT(pvQueryBuffer);
  1052. if (u4QueryBufferLen < sizeof(PARAM_P2P_GET_SD_REQUEST)) {
  1053. *pu4QueryInfoLen = sizeof(PARAM_P2P_GET_SD_REQUEST);
  1054. return WLAN_STATUS_BUFFER_TOO_SHORT;
  1055. }
  1056. DBGLOG(P2P, TRACE, "Get Service Discovery Request\n");
  1057. #if 0
  1058. ucVersionNum = p2pFuncGetVersionNumOfSD(prAdapter);
  1059. if (ucVersionNum == 0) {
  1060. P_PARAM_P2P_GET_SD_REQUEST prP2pGetSdReq = (P_PARAM_P2P_GET_SD_REQUEST) pvQueryBuffer;
  1061. pucPacketBuffer = prP2pGetSdReq->aucPacketContent;
  1062. pu2PacketLength = &prP2pGetSdReq->u2PacketLength;
  1063. pucTA = &prP2pGetSdReq->rTransmitterAddr;
  1064. } else {
  1065. P_PARAM_P2P_GET_SD_REQUEST_EX prP2pGetSdReqEx = (P_PARAM_P2P_GET_SD_REQUEST_EX) NULL;
  1066. prP2pGetSdReqEx = (P_PARAM_P2P_GET_SD_REQUEST) pvQueryBuffer;
  1067. pucPacketBuffer = prP2pGetSdReqEx->aucPacketContent;
  1068. pu2PacketLength = &prP2pGetSdReqEx->u2PacketLength;
  1069. pucTA = &prP2pGetSdReqEx->rTransmitterAddr;
  1070. pucChannelNum = &prP2pGetSdReqEx->ucChannelNum;
  1071. ucSeqNum = prP2pGetSdReqEx->ucSeqNum;
  1072. }
  1073. rWlanStatus = p2pFuncGetServiceDiscoveryFrame(prAdapter,
  1074. pucPacketBuffer,
  1075. (u4QueryBufferLen -
  1076. sizeof(PARAM_P2P_GET_SD_REQUEST)),
  1077. (PUINT_32) pu2PacketLength, pucChannelNum, ucSeqNum);
  1078. #else
  1079. *pu4QueryInfoLen = 0;
  1080. return rWlanStatus;
  1081. #endif
  1082. prWlanHdr = (P_WLAN_MAC_HEADER_T) pucPacketBuffer;
  1083. kalMemCopy(pucTA, prWlanHdr->aucAddr2, MAC_ADDR_LEN);
  1084. if (pu4QueryInfoLen) {
  1085. if (ucVersionNum == 0)
  1086. *pu4QueryInfoLen = (UINT_32) (sizeof(PARAM_P2P_GET_SD_REQUEST) + (*pu2PacketLength));
  1087. else
  1088. *pu4QueryInfoLen = (UINT_32) (sizeof(PARAM_P2P_GET_SD_REQUEST_EX) + (*pu2PacketLength));
  1089. }
  1090. return rWlanStatus;
  1091. } /* end of wlanoidGetP2PSDRequest() */
  1092. /*----------------------------------------------------------------------------*/
  1093. /*!
  1094. * \brief This routine is called to get GAS frame for P2P Service Discovery Response
  1095. *
  1096. * \param[in] prAdapter Pointer to the Adapter structure.
  1097. * \param[out] pvQueryBuffer A pointer to the buffer that holds the result of
  1098. * the query.
  1099. * \param[in] u4QueryBufferLen The length of the query buffer.
  1100. * \param[out] pu4QueryInfoLen If the call is successful, returns the number of
  1101. * bytes written into the query buffer. If the call
  1102. * failed due to invalid length of the query buffer,
  1103. * returns the amount of storage needed.
  1104. *
  1105. * \retval WLAN_STATUS_SUCCESS
  1106. * \retval WLAN_STATUS_INVALID_LENGTH
  1107. * \retval WLAN_STATUS_ADAPTER_NOT_READY
  1108. * \retval WLAN_STATUS_MULTICAST_FULL
  1109. */
  1110. /*----------------------------------------------------------------------------*/
  1111. WLAN_STATUS
  1112. wlanoidGetP2PSDResponse(IN P_ADAPTER_T prAdapter,
  1113. IN PVOID pvQueryBuffer, IN UINT_32 u4QueryBufferLen, OUT PUINT_32 pu4QueryInfoLen)
  1114. {
  1115. WLAN_STATUS rWlanStatus = WLAN_STATUS_SUCCESS;
  1116. P_WLAN_MAC_HEADER_T prWlanHdr = (P_WLAN_MAC_HEADER_T) NULL;
  1117. /* UINT_8 ucSeqNum = 0, */
  1118. UINT_8 ucVersionNum = 0;
  1119. PUINT_8 pucPacketContent = (PUINT_8) NULL, pucTA = (PUINT_8) NULL;
  1120. PUINT_16 pu2PacketLength = (PUINT_16) NULL;
  1121. ASSERT(prAdapter);
  1122. ASSERT(pu4QueryInfoLen);
  1123. if (u4QueryBufferLen)
  1124. ASSERT(pvQueryBuffer);
  1125. if (u4QueryBufferLen < sizeof(PARAM_P2P_GET_SD_RESPONSE)) {
  1126. *pu4QueryInfoLen = sizeof(PARAM_P2P_GET_SD_RESPONSE);
  1127. return WLAN_STATUS_BUFFER_TOO_SHORT;
  1128. }
  1129. DBGLOG(P2P, TRACE, "Get Service Discovery Response\n");
  1130. #if 0
  1131. ucVersionNum = p2pFuncGetVersionNumOfSD(prAdapter);
  1132. if (ucVersionNum == 0) {
  1133. P_PARAM_P2P_GET_SD_RESPONSE prP2pGetSdRsp = (P_PARAM_P2P_GET_SD_RESPONSE) NULL;
  1134. prP2pGetSdRsp = (P_PARAM_P2P_GET_SD_REQUEST) pvQueryBuffer;
  1135. pucPacketContent = prP2pGetSdRsp->aucPacketContent;
  1136. pucTA = &prP2pGetSdRsp->rTransmitterAddr;
  1137. pu2PacketLength = &prP2pGetSdRsp->u2PacketLength;
  1138. } else {
  1139. P_PARAM_P2P_GET_SD_RESPONSE_EX prP2pGetSdRspEx = (P_PARAM_P2P_GET_SD_RESPONSE_EX) NULL;
  1140. prP2pGetSdRspEx = (P_PARAM_P2P_GET_SD_RESPONSE_EX) pvQueryBuffer;
  1141. pucPacketContent = prP2pGetSdRspEx->aucPacketContent;
  1142. pucTA = &prP2pGetSdRspEx->rTransmitterAddr;
  1143. pu2PacketLength = &prP2pGetSdRspEx->u2PacketLength;
  1144. ucSeqNum = prP2pGetSdRspEx->ucSeqNum;
  1145. }
  1146. /* rWlanStatus = p2pFuncGetServiceDiscoveryFrame(prAdapter, */
  1147. /* pucPacketContent, */
  1148. /* (u4QueryBufferLen - sizeof(PARAM_P2P_GET_SD_RESPONSE)), */
  1149. /* (PUINT_32)pu2PacketLength, */
  1150. /* NULL, */
  1151. /* ucSeqNum); */
  1152. #else
  1153. *pu4QueryInfoLen = 0;
  1154. return rWlanStatus;
  1155. #endif
  1156. prWlanHdr = (P_WLAN_MAC_HEADER_T) pucPacketContent;
  1157. kalMemCopy(pucTA, prWlanHdr->aucAddr2, MAC_ADDR_LEN);
  1158. if (pu4QueryInfoLen) {
  1159. if (ucVersionNum == 0)
  1160. *pu4QueryInfoLen = (UINT_32) (sizeof(PARAM_P2P_GET_SD_RESPONSE) + *pu2PacketLength);
  1161. else
  1162. *pu4QueryInfoLen = (UINT_32) (sizeof(PARAM_P2P_GET_SD_RESPONSE_EX) + *pu2PacketLength);
  1163. }
  1164. return rWlanStatus;
  1165. } /* end of wlanoidGetP2PSDResponse() */
  1166. /*----------------------------------------------------------------------------*/
  1167. /*!
  1168. * \brief This routine is called to terminate P2P Service Discovery Phase
  1169. *
  1170. * \param[in] prAdapter Pointer to the Adapter structure.
  1171. * \param[in] pvSetBuffer Pointer to the buffer that holds the data to be set.
  1172. * \param[in] u4SetBufferLen The length of the set buffer.
  1173. * \param[out] pu4SetInfoLen If the call is successful, returns the number of
  1174. * bytes read from the set buffer. If the call failed
  1175. * due to invalid length of the set buffer, returns
  1176. * the amount of storage needed.
  1177. *
  1178. * \retval WLAN_STATUS_SUCCESS
  1179. * \retval WLAN_STATUS_INVALID_LENGTH
  1180. * \retval WLAN_STATUS_ADAPTER_NOT_READY
  1181. * \retval WLAN_STATUS_MULTICAST_FULL
  1182. */
  1183. /*----------------------------------------------------------------------------*/
  1184. WLAN_STATUS
  1185. wlanoidSetP2PTerminateSDPhase(IN P_ADAPTER_T prAdapter,
  1186. IN PVOID pvSetBuffer, IN UINT_32 u4SetBufferLen, OUT PUINT_32 pu4SetInfoLen)
  1187. {
  1188. WLAN_STATUS rWlanStatus = WLAN_STATUS_SUCCESS;
  1189. P_PARAM_P2P_TERMINATE_SD_PHASE prP2pTerminateSD = (P_PARAM_P2P_TERMINATE_SD_PHASE) NULL;
  1190. UINT_8 aucNullAddr[] = NULL_MAC_ADDR;
  1191. do {
  1192. if ((prAdapter == NULL) || (pu4SetInfoLen == NULL))
  1193. break;
  1194. if ((u4SetBufferLen) && (pvSetBuffer == NULL))
  1195. break;
  1196. if (u4SetBufferLen < sizeof(PARAM_P2P_TERMINATE_SD_PHASE)) {
  1197. *pu4SetInfoLen = sizeof(PARAM_P2P_TERMINATE_SD_PHASE);
  1198. rWlanStatus = WLAN_STATUS_BUFFER_TOO_SHORT;
  1199. break;
  1200. }
  1201. prP2pTerminateSD = (P_PARAM_P2P_TERMINATE_SD_PHASE) pvSetBuffer;
  1202. if (EQUAL_MAC_ADDR(prP2pTerminateSD->rPeerAddr, aucNullAddr)) {
  1203. DBGLOG(P2P, TRACE, "Service Discovery Version 2.0\n");
  1204. /* p2pFuncSetVersionNumOfSD(prAdapter, 2); */
  1205. }
  1206. /* rWlanStatus = p2pFsmRunEventSDAbort(prAdapter); */
  1207. } while (FALSE);
  1208. return rWlanStatus;
  1209. } /* end of wlanoidSetP2PTerminateSDPhase() */
  1210. #if CFG_SUPPORT_ANTI_PIRACY
  1211. /*----------------------------------------------------------------------------*/
  1212. /*!
  1213. * \brief This routine is called to
  1214. *
  1215. * \param[in] prAdapter Pointer to the Adapter structure.
  1216. * \param[in] pvSetBuffer Pointer to the buffer that holds the data to be set.
  1217. * \param[in] u4SetBufferLen The length of the set buffer.
  1218. * \param[out] pu4SetInfoLen If the call is successful, returns the number of
  1219. * bytes read from the set buffer. If the call failed
  1220. * due to invalid length of the set buffer, returns
  1221. * the amount of storage needed.
  1222. *
  1223. * \retval WLAN_STATUS_SUCCESS
  1224. * \retval WLAN_STATUS_INVALID_LENGTH
  1225. * \retval WLAN_STATUS_ADAPTER_NOT_READY
  1226. * \retval WLAN_STATUS_MULTICAST_FULL
  1227. */
  1228. /*----------------------------------------------------------------------------*/
  1229. WLAN_STATUS
  1230. wlanoidSetSecCheckRequest(IN P_ADAPTER_T prAdapter,
  1231. IN PVOID pvSetBuffer, IN UINT_32 u4SetBufferLen, OUT PUINT_32 pu4SetInfoLen)
  1232. {
  1233. ASSERT(prAdapter);
  1234. ASSERT(pu4SetInfoLen);
  1235. if (u4SetBufferLen)
  1236. ASSERT(pvSetBuffer);
  1237. return wlanoidSendSetQueryP2PCmd(prAdapter,
  1238. CMD_ID_SEC_CHECK,
  1239. P2P_DEV_BSS_INDEX,
  1240. FALSE,
  1241. TRUE,
  1242. TRUE,
  1243. NULL,
  1244. nicOidCmdTimeoutCommon,
  1245. u4SetBufferLen, (PUINT_8) pvSetBuffer, pvSetBuffer, u4SetBufferLen);
  1246. } /* end of wlanoidSetSecCheckRequest() */
  1247. /*----------------------------------------------------------------------------*/
  1248. /*!
  1249. * \brief This routine is called to
  1250. *
  1251. * \param[in] prAdapter Pointer to the Adapter structure.
  1252. * \param[out] pvQueryBuffer A pointer to the buffer that holds the result of
  1253. * the query.
  1254. * \param[in] u4QueryBufferLen The length of the query buffer.
  1255. * \param[out] pu4QueryInfoLen If the call is successful, returns the number of
  1256. * bytes written into the query buffer. If the call
  1257. * failed due to invalid length of the query buffer,
  1258. * returns the amount of storage needed.
  1259. *
  1260. * \retval WLAN_STATUS_SUCCESS
  1261. * \retval WLAN_STATUS_INVALID_LENGTH
  1262. * \retval WLAN_STATUS_ADAPTER_NOT_READY
  1263. * \retval WLAN_STATUS_MULTICAST_FULL
  1264. */
  1265. /*----------------------------------------------------------------------------*/
  1266. WLAN_STATUS
  1267. wlanoidGetSecCheckResponse(IN P_ADAPTER_T prAdapter,
  1268. IN PVOID pvQueryBuffer, IN UINT_32 u4QueryBufferLen, OUT PUINT_32 pu4QueryInfoLen)
  1269. {
  1270. WLAN_STATUS rWlanStatus = WLAN_STATUS_SUCCESS;
  1271. /* P_WLAN_MAC_HEADER_T prWlanHdr = (P_WLAN_MAC_HEADER_T)NULL; */
  1272. P_GLUE_INFO_T prGlueInfo;
  1273. prGlueInfo = prAdapter->prGlueInfo;
  1274. ASSERT(prAdapter);
  1275. ASSERT(pu4QueryInfoLen);
  1276. if (u4QueryBufferLen)
  1277. ASSERT(pvQueryBuffer);
  1278. if (u4QueryBufferLen > 256)
  1279. u4QueryBufferLen = 256;
  1280. *pu4QueryInfoLen = u4QueryBufferLen;
  1281. #if DBG
  1282. DBGLOG_MEM8(SEC, LOUD, prGlueInfo->prP2PInfo->aucSecCheckRsp, u4QueryBufferLen);
  1283. #endif
  1284. kalMemCopy((PUINT_8) (pvQueryBuffer + OFFSET_OF(IW_P2P_TRANSPORT_STRUCT, aucBuffer)),
  1285. prGlueInfo->prP2PInfo->aucSecCheckRsp, u4QueryBufferLen);
  1286. return rWlanStatus;
  1287. } /* end of wlanoidGetSecCheckResponse() */
  1288. #endif
  1289. WLAN_STATUS
  1290. wlanoidSetNoaParam(IN P_ADAPTER_T prAdapter,
  1291. IN PVOID pvSetBuffer, IN UINT_32 u4SetBufferLen, OUT PUINT_32 pu4SetInfoLen)
  1292. {
  1293. P_PARAM_CUSTOM_NOA_PARAM_STRUCT_T prNoaParam;
  1294. CMD_CUSTOM_NOA_PARAM_STRUCT_T rCmdNoaParam;
  1295. DEBUGFUNC("wlanoidSetNoaParam");
  1296. DBGLOG(INIT, TRACE, "\n");
  1297. ASSERT(prAdapter);
  1298. ASSERT(pu4SetInfoLen);
  1299. *pu4SetInfoLen = sizeof(PARAM_CUSTOM_NOA_PARAM_STRUCT_T);
  1300. if (u4SetBufferLen < sizeof(PARAM_CUSTOM_NOA_PARAM_STRUCT_T))
  1301. return WLAN_STATUS_INVALID_LENGTH;
  1302. ASSERT(pvSetBuffer);
  1303. prNoaParam = (P_PARAM_CUSTOM_NOA_PARAM_STRUCT_T) pvSetBuffer;
  1304. kalMemZero(&rCmdNoaParam, sizeof(CMD_CUSTOM_NOA_PARAM_STRUCT_T));
  1305. rCmdNoaParam.u4NoaDurationMs = prNoaParam->u4NoaDurationMs;
  1306. rCmdNoaParam.u4NoaIntervalMs = prNoaParam->u4NoaIntervalMs;
  1307. rCmdNoaParam.u4NoaCount = prNoaParam->u4NoaCount;
  1308. #if 0
  1309. return wlanSendSetQueryCmd(prAdapter,
  1310. CMD_ID_SET_NOA_PARAM,
  1311. TRUE,
  1312. FALSE,
  1313. TRUE,
  1314. nicCmdEventSetCommon,
  1315. nicOidCmdTimeoutCommon,
  1316. sizeof(CMD_CUSTOM_NOA_PARAM_STRUCT_T),
  1317. (PUINT_8) &rCmdNoaParam, pvSetBuffer, u4SetBufferLen);
  1318. #else
  1319. return wlanoidSendSetQueryP2PCmd(prAdapter,
  1320. CMD_ID_SET_NOA_PARAM,
  1321. prNoaParam->ucBssIdx,
  1322. TRUE,
  1323. FALSE,
  1324. TRUE,
  1325. NULL,
  1326. nicOidCmdTimeoutCommon,
  1327. sizeof(CMD_CUSTOM_NOA_PARAM_STRUCT_T),
  1328. (PUINT_8) &rCmdNoaParam, pvSetBuffer, u4SetBufferLen);
  1329. #endif
  1330. }
  1331. WLAN_STATUS
  1332. wlanoidSetOppPsParam(IN P_ADAPTER_T prAdapter,
  1333. IN PVOID pvSetBuffer, IN UINT_32 u4SetBufferLen, OUT PUINT_32 pu4SetInfoLen)
  1334. {
  1335. P_PARAM_CUSTOM_OPPPS_PARAM_STRUCT_T prOppPsParam;
  1336. CMD_CUSTOM_OPPPS_PARAM_STRUCT_T rCmdOppPsParam;
  1337. DEBUGFUNC("wlanoidSetOppPsParam");
  1338. DBGLOG(INIT, TRACE, "\n");
  1339. ASSERT(prAdapter);
  1340. ASSERT(pu4SetInfoLen);
  1341. *pu4SetInfoLen = sizeof(PARAM_CUSTOM_OPPPS_PARAM_STRUCT_T);
  1342. if (u4SetBufferLen < sizeof(PARAM_CUSTOM_OPPPS_PARAM_STRUCT_T))
  1343. return WLAN_STATUS_INVALID_LENGTH;
  1344. ASSERT(pvSetBuffer);
  1345. prOppPsParam = (P_PARAM_CUSTOM_OPPPS_PARAM_STRUCT_T) pvSetBuffer;
  1346. kalMemZero(&rCmdOppPsParam, sizeof(CMD_CUSTOM_OPPPS_PARAM_STRUCT_T));
  1347. rCmdOppPsParam.u4CTwindowMs = prOppPsParam->u4CTwindowMs;
  1348. #if 0
  1349. return wlanSendSetQueryCmd(prAdapter,
  1350. CMD_ID_SET_OPPPS_PARAM,
  1351. TRUE,
  1352. FALSE,
  1353. TRUE,
  1354. nicCmdEventSetCommon,
  1355. nicOidCmdTimeoutCommon,
  1356. sizeof(CMD_CUSTOM_OPPPS_PARAM_STRUCT_T),
  1357. (PUINT_8) &rCmdOppPsParam, pvSetBuffer, u4SetBufferLen);
  1358. #else
  1359. return wlanoidSendSetQueryP2PCmd(prAdapter,
  1360. CMD_ID_SET_NOA_PARAM,
  1361. prOppPsParam->ucBssIdx,
  1362. TRUE,
  1363. FALSE,
  1364. TRUE,
  1365. NULL,
  1366. nicOidCmdTimeoutCommon,
  1367. sizeof(CMD_CUSTOM_OPPPS_PARAM_STRUCT_T),
  1368. (PUINT_8) &rCmdOppPsParam, pvSetBuffer, u4SetBufferLen);
  1369. #endif
  1370. }
  1371. WLAN_STATUS
  1372. wlanoidSetUApsdParam(IN P_ADAPTER_T prAdapter,
  1373. IN PVOID pvSetBuffer, IN UINT_32 u4SetBufferLen, OUT PUINT_32 pu4SetInfoLen)
  1374. {
  1375. P_PARAM_CUSTOM_UAPSD_PARAM_STRUCT_T prUapsdParam;
  1376. CMD_CUSTOM_UAPSD_PARAM_STRUCT_T rCmdUapsdParam;
  1377. P_PM_PROFILE_SETUP_INFO_T prPmProfSetupInfo;
  1378. P_BSS_INFO_T prBssInfo;
  1379. DEBUGFUNC("wlanoidSetUApsdParam");
  1380. DBGLOG(INIT, TRACE, "\n");
  1381. ASSERT(prAdapter);
  1382. ASSERT(pu4SetInfoLen);
  1383. *pu4SetInfoLen = sizeof(PARAM_CUSTOM_UAPSD_PARAM_STRUCT_T);
  1384. if (u4SetBufferLen < sizeof(PARAM_CUSTOM_UAPSD_PARAM_STRUCT_T))
  1385. return WLAN_STATUS_INVALID_LENGTH;
  1386. ASSERT(pvSetBuffer);
  1387. prUapsdParam = (P_PARAM_CUSTOM_UAPSD_PARAM_STRUCT_T) pvSetBuffer;
  1388. prBssInfo = GET_BSS_INFO_BY_INDEX(prAdapter, prUapsdParam->ucBssIdx);
  1389. prPmProfSetupInfo = &prBssInfo->rPmProfSetupInfo;
  1390. kalMemZero(&rCmdUapsdParam, sizeof(CMD_CUSTOM_OPPPS_PARAM_STRUCT_T));
  1391. rCmdUapsdParam.fgEnAPSD = prUapsdParam->fgEnAPSD;
  1392. rCmdUapsdParam.fgEnAPSD_AcBe = prUapsdParam->fgEnAPSD_AcBe;
  1393. rCmdUapsdParam.fgEnAPSD_AcBk = prUapsdParam->fgEnAPSD_AcBk;
  1394. rCmdUapsdParam.fgEnAPSD_AcVo = prUapsdParam->fgEnAPSD_AcVo;
  1395. rCmdUapsdParam.fgEnAPSD_AcVi = prUapsdParam->fgEnAPSD_AcVi;
  1396. prPmProfSetupInfo->ucBmpDeliveryAC =
  1397. ((prUapsdParam->fgEnAPSD_AcBe << 0) |
  1398. (prUapsdParam->fgEnAPSD_AcBk << 1) |
  1399. (prUapsdParam->fgEnAPSD_AcVi << 2) | (prUapsdParam->fgEnAPSD_AcVo << 3));
  1400. prPmProfSetupInfo->ucBmpTriggerAC =
  1401. ((prUapsdParam->fgEnAPSD_AcBe << 0) |
  1402. (prUapsdParam->fgEnAPSD_AcBk << 1) |
  1403. (prUapsdParam->fgEnAPSD_AcVi << 2) | (prUapsdParam->fgEnAPSD_AcVo << 3));
  1404. rCmdUapsdParam.ucMaxSpLen = prUapsdParam->ucMaxSpLen;
  1405. prPmProfSetupInfo->ucUapsdSp = prUapsdParam->ucMaxSpLen;
  1406. #if 0
  1407. return wlanSendSetQueryCmd(prAdapter,
  1408. CMD_ID_SET_UAPSD_PARAM,
  1409. TRUE,
  1410. FALSE,
  1411. TRUE,
  1412. nicCmdEventSetCommon,
  1413. nicOidCmdTimeoutCommon,
  1414. sizeof(CMD_CUSTOM_OPPPS_PARAM_STRUCT_T),
  1415. (PUINT_8) &rCmdUapsdParam, pvSetBuffer, u4SetBufferLen);
  1416. #else
  1417. return wlanoidSendSetQueryP2PCmd(prAdapter,
  1418. CMD_ID_SET_UAPSD_PARAM,
  1419. prBssInfo->ucBssIndex,
  1420. TRUE,
  1421. FALSE,
  1422. TRUE,
  1423. NULL,
  1424. nicOidCmdTimeoutCommon,
  1425. sizeof(CMD_CUSTOM_OPPPS_PARAM_STRUCT_T),
  1426. (PUINT_8) &rCmdUapsdParam, pvSetBuffer, u4SetBufferLen);
  1427. #endif
  1428. }
  1429. WLAN_STATUS
  1430. wlanoidQueryP2pOpChannel(IN P_ADAPTER_T prAdapter,
  1431. IN PVOID pvQueryBuffer, IN UINT_32 u4QueryBufferLen, OUT PUINT_32 pu4QueryInfoLen)
  1432. {
  1433. WLAN_STATUS rResult = WLAN_STATUS_FAILURE;
  1434. /* PUINT_8 pucOpChnl = (PUINT_8)pvQueryBuffer; */
  1435. do {
  1436. if ((prAdapter == NULL) || (pu4QueryInfoLen == NULL))
  1437. break;
  1438. if ((u4QueryBufferLen) && (pvQueryBuffer == NULL))
  1439. break;
  1440. if (u4QueryBufferLen < sizeof(UINT_8)) {
  1441. *pu4QueryInfoLen = sizeof(UINT_8);
  1442. rResult = WLAN_STATUS_BUFFER_TOO_SHORT;
  1443. break;
  1444. }
  1445. #if 0
  1446. if (!p2pFuncGetCurrentOpChnl(prAdapter, pucOpChnl)) {
  1447. rResult = WLAN_STATUS_INVALID_DATA;
  1448. break;
  1449. }
  1450. #else
  1451. rResult = WLAN_STATUS_INVALID_DATA;
  1452. break;
  1453. #endif
  1454. *pu4QueryInfoLen = sizeof(UINT_8);
  1455. rResult = WLAN_STATUS_SUCCESS;
  1456. } while (FALSE);
  1457. return rResult;
  1458. } /* wlanoidQueryP2pOpChannel */
  1459. WLAN_STATUS
  1460. wlanoidQueryP2pVersion(IN P_ADAPTER_T prAdapter,
  1461. IN PVOID pvQueryBuffer, IN UINT_32 u4QueryBufferLen, OUT PUINT_32 pu4QueryInfoLen)
  1462. {
  1463. WLAN_STATUS rResult = WLAN_STATUS_FAILURE;
  1464. /* PUINT_8 pucVersionNum = (PUINT_8)pvQueryBuffer; */
  1465. do {
  1466. if ((prAdapter == NULL) || (pu4QueryInfoLen == NULL))
  1467. break;
  1468. if ((u4QueryBufferLen) && (pvQueryBuffer == NULL))
  1469. break;
  1470. if (u4QueryBufferLen < sizeof(UINT_8)) {
  1471. *pu4QueryInfoLen = sizeof(UINT_8);
  1472. rResult = WLAN_STATUS_BUFFER_TOO_SHORT;
  1473. break;
  1474. }
  1475. } while (FALSE);
  1476. return rResult;
  1477. } /* wlanoidQueryP2pVersion */
  1478. #if CFG_SUPPORT_HOTSPOT_WPS_MANAGER
  1479. /*----------------------------------------------------------------------------*/
  1480. /*!
  1481. * \brief This routine is used to set the WPS mode.
  1482. *
  1483. * \param[in] pvAdapter Pointer to the Adapter structure.
  1484. * \param[in] pvSetBuffer A pointer to the buffer that holds the data to be set.
  1485. * \param[in] u4SetBufferLen The length of the set buffer.
  1486. * \param[out] pu4SetInfoLen If the call is successful, returns the number of
  1487. * bytes read from the set buffer. If the call failed
  1488. * due to invalid length of the set buffer, returns
  1489. * the amount of storage needed.
  1490. *
  1491. * \retval WLAN_STATUS_SUCCESS
  1492. * \retval WLAN_STATUS_INVALID_LENGTH
  1493. */
  1494. /*----------------------------------------------------------------------------*/
  1495. WLAN_STATUS
  1496. wlanoidSetP2pWPSmode(IN P_ADAPTER_T prAdapter,
  1497. IN PVOID pvSetBuffer, IN UINT_32 u4SetBufferLen, OUT PUINT_32 pu4SetInfoLen)
  1498. {
  1499. WLAN_STATUS status;
  1500. UINT_32 u4IsWPSmode = 0;
  1501. DEBUGFUNC("wlanoidSetP2pWPSmode");
  1502. ASSERT(prAdapter);
  1503. ASSERT(pu4SetInfoLen);
  1504. if (pvSetBuffer)
  1505. u4IsWPSmode = *(PUINT_32) pvSetBuffer;
  1506. else
  1507. u4IsWPSmode = 0;
  1508. if (u4IsWPSmode)
  1509. prAdapter->rWifiVar.prP2PConnSettings->fgIsWPSMode = 1;
  1510. else
  1511. prAdapter->rWifiVar.prP2PConnSettings->fgIsWPSMode = 0;
  1512. status = nicUpdateBss(prAdapter, P2P_DEV_BSS_INDEX);
  1513. return status;
  1514. } /* end of wlanoidSetP2pWPSmode() */
  1515. #endif
  1516. WLAN_STATUS
  1517. wlanoidSetP2pSupplicantVersion(IN P_ADAPTER_T prAdapter,
  1518. IN PVOID pvSetBuffer, IN UINT_32 u4SetBufferLen, OUT PUINT_32 pu4SetInfoLen)
  1519. {
  1520. WLAN_STATUS rResult = WLAN_STATUS_FAILURE;
  1521. UINT_8 ucVersionNum;
  1522. do {
  1523. if ((prAdapter == NULL) || (pu4SetInfoLen == NULL)) {
  1524. rResult = WLAN_STATUS_INVALID_DATA;
  1525. break;
  1526. }
  1527. if ((u4SetBufferLen) && (pvSetBuffer == NULL)) {
  1528. rResult = WLAN_STATUS_INVALID_DATA;
  1529. break;
  1530. }
  1531. *pu4SetInfoLen = sizeof(UINT_8);
  1532. if (u4SetBufferLen < sizeof(UINT_8)) {
  1533. rResult = WLAN_STATUS_INVALID_LENGTH;
  1534. break;
  1535. }
  1536. ucVersionNum = *((PUINT_8) pvSetBuffer);
  1537. rResult = WLAN_STATUS_SUCCESS;
  1538. } while (FALSE);
  1539. return rResult;
  1540. } /* wlanoidSetP2pSupplicantVersion */
  1541. #if CFG_SUPPORT_P2P_RSSI_QUERY
  1542. WLAN_STATUS
  1543. wlanoidQueryP2pRssi(IN P_ADAPTER_T prAdapter,
  1544. IN PVOID pvQueryBuffer, IN UINT_32 u4QueryBufferLen, OUT PUINT_32 pu4QueryInfoLen)
  1545. {
  1546. DEBUGFUNC("wlanoidQueryP2pRssi");
  1547. ASSERT(prAdapter);
  1548. ASSERT(pu4QueryInfoLen);
  1549. if (u4QueryBufferLen)
  1550. ASSERT(pvQueryBuffer);
  1551. *pu4QueryInfoLen = sizeof(PARAM_RSSI);
  1552. /* Check for query buffer length */
  1553. if (u4QueryBufferLen < *pu4QueryInfoLen) {
  1554. DBGLOG(REQ, WARN, "Too short length %ld\n", u4QueryBufferLen);
  1555. return WLAN_STATUS_BUFFER_TOO_SHORT;
  1556. }
  1557. if (prAdapter->fgIsP2pLinkQualityValid == TRUE &&
  1558. (kalGetTimeTick() - prAdapter->rP2pLinkQualityUpdateTime) <= CFG_LINK_QUALITY_VALID_PERIOD) {
  1559. PARAM_RSSI rRssi;
  1560. rRssi = (PARAM_RSSI) prAdapter->rP2pLinkQuality.cRssi; /* ranged from (-128 ~ 30) in unit of dBm */
  1561. if (rRssi > PARAM_WHQL_RSSI_MAX_DBM)
  1562. rRssi = PARAM_WHQL_RSSI_MAX_DBM;
  1563. else if (rRssi < PARAM_WHQL_RSSI_MIN_DBM)
  1564. rRssi = PARAM_WHQL_RSSI_MIN_DBM;
  1565. kalMemCopy(pvQueryBuffer, &rRssi, sizeof(PARAM_RSSI));
  1566. return WLAN_STATUS_SUCCESS;
  1567. }
  1568. #ifdef LINUX
  1569. return wlanSendSetQueryCmd(prAdapter,
  1570. CMD_ID_GET_LINK_QUALITY,
  1571. FALSE,
  1572. TRUE,
  1573. TRUE,
  1574. nicCmdEventQueryLinkQuality,
  1575. nicOidCmdTimeoutCommon,
  1576. *pu4QueryInfoLen, pvQueryBuffer, pvQueryBuffer, u4QueryBufferLen);
  1577. #else
  1578. return wlanSendSetQueryCmd(prAdapter,
  1579. CMD_ID_GET_LINK_QUALITY,
  1580. FALSE,
  1581. TRUE,
  1582. TRUE,
  1583. nicCmdEventQueryLinkQuality,
  1584. nicOidCmdTimeoutCommon, 0, NULL, pvQueryBuffer, u4QueryBufferLen);
  1585. #endif
  1586. } /* wlanoidQueryP2pRssi */
  1587. #endif