p2p_fsm.c 73 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271
  1. /*
  2. ** Id: //Department/DaVinci/TRUNK/WiFi_P2P_Driver/mgmt/p2p_fsm.c#61
  3. */
  4. /*! \file "p2p_fsm.c"
  5. * \brief This file defines the FSM for P2P Module.
  6. *
  7. * This file defines the FSM for P2P Module.
  8. */
  9. /*
  10. ** Log: p2p_fsm.c
  11. **
  12. ** 07 25 2014 eason.tsai
  13. ** AOSP
  14. **
  15. ** 08 22 2013 yuche.tsai
  16. ** [BORA00002761] [MT6630][Wi-Fi Direct][Driver] Group Interface formation
  17. ** [BORA00000779] [MT6620] Emulation For TX Code Check In
  18. ** Make P2P group interface formation success.
  19. **
  20. ** 08 05 2013 terry.wu
  21. ** [BORA00002207] [MT6630 Wi-Fi] TXM & MQM Implementation
  22. ** 1. Add SW rate definition
  23. ** 2. Add HW default rate selection logic from FW
  24. **
  25. ** 07 31 2013 yuche.tsai
  26. ** [BORA00002398] [MT6630][Volunteer Patch] P2P Driver Re-Design for Multiple BSS support
  27. ** Change private data of net device.
  28. **
  29. ** 07 30 2013 yuche.tsai
  30. ** [BORA00002398] [MT6630][Volunteer Patch] P2P Driver Re-Design for Multiple BSS support
  31. ** Driver update for Hot-Spot mode.
  32. **
  33. ** 07 26 2013 terry.wu
  34. ** [BORA00002207] [MT6630 Wi-Fi] TXM & MQM Implementation
  35. ** 1. Reduce extra Tx frame header parsing
  36. ** 2. Add TX port control
  37. ** 3. Add net interface to BSS binding
  38. **
  39. ** 02 27 2013 yuche.tsai
  40. ** [BORA00002398] [MT6630][Volunteer Patch] P2P Driver Re-Design for Multiple BSS support
  41. ** Add aaa_fsm.c, p2p_ie.c, fix compile warning & error.
  42. **
  43. ** 02 27 2013 yuche.tsai
  44. ** [BORA00002398] [MT6630][Volunteer Patch] P2P Driver Re-Design for Multiple BSS support
  45. ** Add new code, fix compile warning.
  46. **
  47. ** 01 21 2013 terry.wu
  48. ** [BORA00002207] [MT6630 Wi-Fi] TXM & MQM Implementation
  49. ** Update TX path based on new ucBssIndex modifications.
  50. **
  51. ** 09 17 2012 cm.chang
  52. ** [BORA00002149] [MT6630 Wi-Fi] Initial software development
  53. ** Duplicate source from MT6620 v2.3 driver branch
  54. ** (Davinci label: MT6620_WIFI_Driver_V2_3_120913_1942_As_MT6630_Base)
  55. **
  56. ** 08 30 2012 yuche.tsai
  57. ** NULL
  58. ** Fix disconnect issue possible leads KE.
  59. **
  60. ** 08 24 2012 cp.wu
  61. ** [WCXRP00001269] [MT6620 Wi-Fi][Driver] cfg80211 porting merge back to DaVinci
  62. ** .
  63. **
  64. ** 08 24 2012 cp.wu
  65. ** [WCXRP00001269] [MT6620 Wi-Fi][Driver] cfg80211 porting merge back to DaVinci
  66. ** cfg80211 support merge back from ALPS.JB to DaVinci - MT6620 Driver v2.3 branch.
  67. **
  68. ** 08 24 2012 yuche.tsai
  69. ** NULL
  70. ** Fix bug of invitation request.
  71. **
  72. ** 08 20 2012 yuche.tsai
  73. ** NULL
  74. ** Try to fix frame register KE issue.
  75. **
  76. ** 08 15 2012 yuche.tsai
  77. ** NULL
  78. ** Fix compile warning.
  79. **
  80. ** 08 07 2012 yuche.tsai
  81. ** NULL
  82. ** Disable BOW when p2p is active.
  83. **
  84. ** 08 06 2012 yuche.tsai
  85. ** NULL
  86. ** Bug fix for KE when load/unload AP mode.
  87. **
  88. ** 08 03 2012 yuche.tsai
  89. ** NULL
  90. ** Fix possible KE when load & unload driver.
  91. **
  92. ** 07 31 2012 yuche.tsai
  93. ** NULL
  94. ** Update Active/Deactive network policy for P2P network.
  95. ** Highly related to power saving.
  96. **
  97. ** 07 27 2012 yuche.tsai
  98. ** NULL
  99. ** Fix bug for KE when unload..
  100. **
  101. ** 07 25 2012 yuche.tsai
  102. ** NULL
  103. ** Buf fix for starting AP mode.
  104. **
  105. ** 07 24 2012 yuche.tsai
  106. ** NULL
  107. ** Bug fix for JB.
  108. **
  109. ** 07 19 2012 yuche.tsai
  110. ** NULL
  111. ** Code update for JB.
  112. *
  113. * 07 17 2012 yuche.tsai
  114. * NULL
  115. * Compile no error before trial run.
  116. *
  117. * 07 05 2011 yuche.tsai
  118. * [WCXRP00000821] [Volunteer Patch][WiFi Direct][Driver] WiFi Direct Connection Speed Issue
  119. * Fix the compile flag of enhancement.
  120. *
  121. * 07 05 2011 yuche.tsai
  122. * [WCXRP00000808] [Volunteer Patch][MT6620][Driver/FW] Device discoverability issue fix
  123. * Change device discoverability methodology. From driver SCAN to FW lock channel.
  124. *
  125. * 07 05 2011 yuche.tsai
  126. * [WCXRP00000821] [Volunteer Patch][WiFi Direct][Driver] WiFi Direct Connection Speed Issue
  127. * Add wifi direct connection enhancement method I, II & VI.
  128. *
  129. * 07 05 2011 yuche.tsai
  130. * [WCXRP00000833] [Volunteer Patch][WiFi Direct][Driver] Service Discovery Frame RX Indicate Issue
  131. * Fix Service Discovery Race Condition Issue.
  132. *
  133. * 06 23 2011 cp.wu
  134. * [WCXRP00000798] [MT6620 Wi-Fi][Firmware] Follow-ups for WAPI frequency offset workaround in firmware SCN module
  135. * change parameter name from PeerAddr to BSSID
  136. *
  137. * 06 21 2011 yuche.tsai
  138. * [WCXRP00000799] [Volunteer Patch][MT6620][Driver] Connection Indication Twice Issue.
  139. * Fix an issue of accepting connection of GO.
  140. *
  141. * 06 21 2011 yuche.tsai
  142. * [WCXRP00000775] [Volunteer Patch][MT6620][Driver] Dynamic enable SD capability
  143. * Drop GAS frame when SD is not enabled.
  144. *
  145. * 06 20 2011 yuche.tsai
  146. * NULL
  147. * Fix compile error.
  148. *
  149. * 06 20 2011 yuche.tsai
  150. * [WCXRP00000799] [Volunteer Patch][MT6620][Driver] Connection Indication Twice Issue.
  151. * Fix connection indication twice issue.
  152. *
  153. * 06 20 2011 cp.wu
  154. * [WCXRP00000798] [MT6620 Wi-Fi][Firmware] Follow-ups for WAPI frequency offset workaround in firmware SCN module
  155. * 1. specify target's BSSID when requesting channel privilege.
  156. * 2. pass BSSID information to firmware domain
  157. *
  158. * 06 20 2011 yuche.tsai
  159. * [WCXRP00000795] [Volunteer Patch][MT6620][Driver] GO can not connect second device issue
  160. * Solve P2P GO can not formation with second device issue.
  161. *
  162. * 06 14 2011 yuche.tsai
  163. * NULL
  164. * Change disconnect feature.
  165. *
  166. * 06 10 2011 yuche.tsai
  167. * [WCXRP00000775] [Volunteer Patch][MT6620][Driver] Dynamic enable SD capability[WCXRP00000776] [Need
  168. * Patch][MT6620][Driver] MT6620 response probe request of P2P device with P2P IE under Hot Spot mode.
  169. * 1. Dynamic enable SD capability after P2P supplicant ready.
  170. * 2. Avoid response probe respone with p2p IE when under hot spot mode.
  171. *
  172. * 06 07 2011 yuche.tsai
  173. * [WCXRP00000763] [Volunteer Patch][MT6620][Driver] RX Service Discovery Frame under AP mode Issue
  174. * Fix RX SD request under AP mode issue.
  175. *
  176. * 06 02 2011 cp.wu
  177. * [WCXRP00000681] [MT5931][Firmware] HIF code size reduction
  178. * eliminate unused parameters for SAA-FSM
  179. *
  180. * 05 26 2011 yuche.tsai
  181. * [WCXRP00000745] Support accepting connection after one Group Connection Lost.
  182. *
  183. * After Group Formation & lost connection, if MT6620 behave as:
  184. *
  185. * 1. GO: It would keep under GO state until been dissolved by supplicant.
  186. *
  187. * At this time, other P2P device can use join method to join this group.
  188. *
  189. *
  190. * 2. GC: It would keep on searching target GO or target device until been dissolved by supplicant.
  191. *
  192. * At this time, it would ignore other P2P device formation request.
  193. *
  194. *
  195. * --
  196. *
  197. * Modification: Make driver to accept GO NEGO REQ at this time, to let user decide to accept new connection or not.
  198. *
  199. * [Volunteer Patch][MT6620][Driver]
  200. * Driver would indicate connection request, if password ID is not ready but connection request is issued.
  201. *
  202. * 05 18 2011 yuche.tsai
  203. * [WCXRP00000728] [Volunteer Patch][MT6620][Driver] Service Discovery Request TX issue.
  204. * A solution for both connection request & IO control.
  205. *
  206. * 05 16 2011 yuche.tsai
  207. * [WCXRP00000728] [Volunteer Patch][MT6620][Driver] Service Discovery Request TX issue.
  208. * Fix SD request can not send out issue.
  209. *
  210. * 05 09 2011 terry.wu
  211. * [WCXRP00000711] [MT6620 Wi-Fi][Driver] Set Initial value of StaType in StaRec for Hotspot Client
  212. * Set initial value of StaType in StaRec for hotspot client.
  213. *
  214. * 05 04 2011 yuche.tsai
  215. * [WCXRP00000697] [Volunteer Patch][MT6620][Driver]
  216. * Bug fix for p2p descriptor is NULL if BSS descriptor is found first.
  217. *
  218. * 05 04 2011 yuche.tsai
  219. * NULL
  220. * Support partial persistent group function.
  221. *
  222. * 05 02 2011 yuche.tsai
  223. * [WCXRP00000693] [Volunteer Patch][MT6620][Driver] Clear Formation Flag after TX lifetime timeout.
  224. * Clear formation flag after formation timeout.
  225. *
  226. * 04 20 2011 yuche.tsai
  227. * [WCXRP00000668] [Volunteer Patch][MT6620][Driver] Possible race condition when add scan & query scan result at the
  228. * same time.
  229. * Fix side effect while starting ATGO.
  230. *
  231. * 04 20 2011 yuche.tsai
  232. * NULL
  233. * Fix ASSERT issue in FW, side effect of last change.
  234. *
  235. * 04 19 2011 yuche.tsai
  236. * [WCXRP00000668] [Volunteer Patch][MT6620][Driver] Possible race condition when add scan & query scan result at the
  237. * same time.
  238. * Workaround for multiple device connection, before invitation ready.
  239. *
  240. * 04 19 2011 yuche.tsai
  241. * [WCXRP00000665] [Wifi Direct][MT6620 E4] When use Ralink's dongle to establish wifi direct connection with PBC. But
  242. * 6573 always not pop accept option to establish connection.
  243. * Support connection indication when GO NEGO REQ doesn't have configure method, instead it has PasswordID.
  244. *
  245. * 04 18 2011 yuche.tsai
  246. * NULL
  247. * Fix error.
  248. *
  249. * 04 14 2011 yuche.tsai
  250. * [WCXRP00000646] [Volunteer Patch][MT6620][FW/Driver] Sigma Test Modification for some test case.
  251. * Fix a connection issue.
  252. *
  253. * 04 14 2011 yuche.tsai
  254. * [WCXRP00000646] [Volunteer Patch][MT6620][FW/Driver] Sigma Test Modification for some test case.
  255. * Fix the channel issue of AP mode.
  256. *
  257. * 04 14 2011 yuche.tsai
  258. * [WCXRP00000646] [Volunteer Patch][MT6620][FW/Driver] Sigma Test Modification for some test case.
  259. * Connection flow refine for Sigma test.
  260. *
  261. * 04 09 2011 yuche.tsai
  262. * [WCXRP00000624] [Volunteer Patch][MT6620][Driver] Add device discoverability support for GO.
  263. * Fix Device discoverability related issue.
  264. *
  265. * 04 09 2011 yuche.tsai
  266. * [WCXRP00000624] [Volunteer Patch][MT6620][Driver] Add device discoverability support for GO.
  267. * Fix bug for Device Discoverability.
  268. *
  269. * 04 08 2011 yuche.tsai
  270. * [WCXRP00000624] [Volunteer Patch][MT6620][Driver] Add device discoverability support for GO.
  271. * Fix compile error.
  272. *
  273. * 04 08 2011 yuche.tsai
  274. * [WCXRP00000624] [Volunteer Patch][MT6620][Driver] Add device discoverability support for GO.
  275. * Add device discoverability support.
  276. *
  277. * 03 28 2011 yuche.tsai
  278. * NULL
  279. * Fix a possible issue for retry join when media status connected.
  280. *
  281. * 03 25 2011 yuche.tsai
  282. * NULL
  283. * Improve some error handleing.
  284. *
  285. * 03 24 2011 yuche.tsai
  286. * NULL
  287. * Assign AID before change STA_REC state to state 3.
  288. *
  289. * 03 23 2011 yuche.tsai
  290. * NULL
  291. * Fix Response Rate Issue when TX Auth Rsp Frame under P2P Mode.
  292. *
  293. * 03 23 2011 yuche.tsai
  294. * NULL
  295. * Fix issue of connection to one GC.
  296. *
  297. * 03 23 2011 yuche.tsai
  298. * NULL
  299. * Fix ASSERT issue when starting Hot-spot.
  300. *
  301. * 03 22 2011 yuche.tsai
  302. * NULL
  303. * When Target Information is not available, change to passive mode.
  304. *
  305. * 03 22 2011 yuche.tsai
  306. * NULL
  307. * Fix one connection issue while using Keypad to connect a GO.
  308. *
  309. * 03 22 2011 yuche.tsai
  310. * NULL
  311. * 1. Fix two issues that may cause kernel panic.
  312. *
  313. * 03 22 2011 yuche.tsai
  314. * NULL
  315. * Fix GC connect to other device issue.
  316. *
  317. * 03 22 2011 yuche.tsai
  318. * NULL
  319. * 1.Shorten the LISTEN interval.
  320. * 2. Fix IF address issue when we are GO
  321. * 3. Fix LISTEN channel issue.
  322. *
  323. * 03 22 2011 yuche.tsai
  324. * NULL
  325. * Modify formation policy setting.
  326. *
  327. * 03 21 2011 yuche.tsai
  328. * NULL
  329. * Solve Listen State doesn't response probe response issue.
  330. *
  331. * 03 21 2011 yuche.tsai
  332. * NULL
  333. * Change P2P Connection Request Flow.
  334. *
  335. * 03 19 2011 yuche.tsai
  336. * [WCXRP00000584] [Volunteer Patch][MT6620][Driver] Add beacon timeout support for WiFi Direct.
  337. * Add beacon timeout support.
  338. *
  339. * 03 19 2011 yuche.tsai
  340. * [WCXRP00000583] [Volunteer Patch][MT6620][Driver] P2P connection of the third peer issue
  341. * Indicate the correct Group SSID when join on Group.
  342. *
  343. * 03 19 2011 yuche.tsai
  344. * [WCXRP00000583] [Volunteer Patch][MT6620][Driver] P2P connection of the third peer issue
  345. * Support the third P2P device to join GO/GC group.
  346. *
  347. * 03 19 2011 yuche.tsai
  348. * [WCXRP00000581] [Volunteer Patch][MT6620][Driver] P2P IE in Assoc Req Issue
  349. * Append P2P IE in Assoc Req, so that GC can be discovered in probe response of GO.
  350. *
  351. * 03 18 2011 yuche.tsai
  352. * [WCXRP00000578] [Volunteer Patch][MT6620][Driver] Separate Connection Request from general IOCTL
  353. * Separate connection request from general IOCTL.
  354. *
  355. * 03 18 2011 yuche.tsai
  356. * [WCXRP00000574] [Volunteer Patch][MT6620][Driver] Modify P2P FSM Connection Flow
  357. * Modify connection flow after Group Formation Complete, or device connect to a GO.
  358. * Instead of request channel & connect directly, we use scan to allocate channel bandwidth & connect after RX BCN.
  359. *
  360. * 03 17 2011 yuche.tsai
  361. * NULL
  362. * When AIS is connect to an AP, Hot Spot would be enabled under fixed same channel.
  363. *
  364. * 03 17 2011 yuche.tsai
  365. * NULL
  366. * Solve the Group Info IE in Probe Response incorrect issue.
  367. *
  368. * 03 17 2011 yuche.tsai
  369. * NULL
  370. * Release Channel after Join Complete.
  371. *
  372. * 03 16 2011 wh.su
  373. * [WCXRP00000530] [MT6620 Wi-Fi] [Driver] skip doing p2pRunEventAAAComplete after send assoc response Tx Done
  374. * enable the protected while at P2P start GO, and skip some security check .
  375. *
  376. * 03 15 2011 yuche.tsai
  377. * [WCXRP00000560] [Volunteer Patch][MT6620][Driver] P2P Connection from UI using KEY/DISPLAY issue
  378. * Fix local configure method issue.
  379. *
  380. * 03 15 2011 yuche.tsai
  381. * [WCXRP00000560] [Volunteer Patch][MT6620][Driver] P2P Connection from UI using KEY/DISPLAY issue
  382. * Fix some configure method issue.
  383. *
  384. * 03 14 2011 yuche.tsai
  385. * NULL
  386. * .
  387. *
  388. * 03 14 2011 yuche.tsai
  389. * NULL
  390. * Fix password ID issue.
  391. *
  392. * 03 10 2011 yuche.tsai
  393. * NULL
  394. * Add P2P API.
  395. *
  396. * 03 08 2011 yuche.tsai
  397. * [WCXRP00000480] [Volunteer Patch][MT6620][Driver] WCS IE format issue[WCXRP00000509] [Volunteer Patch][MT6620][Driver]
  398. * Kernal panic when remove p2p module.
  399. * .
  400. *
  401. * 03 07 2011 yuche.tsai
  402. * [WCXRP00000502] [Volunteer Patch][MT6620][Driver] Fix group ID issue when doing Group Formation.
  403. * .
  404. *
  405. * 03 07 2011 wh.su
  406. * [WCXRP00000506] [MT6620 Wi-Fi][Driver][FW] Add Security check related code
  407. * rename the define to anti_pviracy.
  408. *
  409. * 03 05 2011 wh.su
  410. * [WCXRP00000506] [MT6620 Wi-Fi][Driver][FW] Add Security check related code
  411. * add the code to get the check rsponse and indicate to app.
  412. *
  413. * 03 04 2011 wh.su
  414. * [WCXRP00000510] [MT6620 Wi-Fi] [Driver] Fixed the CTIA enter test mode issue
  415. * fixed the p2p action frame type check for device request indication.
  416. *
  417. * 03 02 2011 yuche.tsai
  418. * [WCXRP00000245] 1. Invitation Request/Response.
  419. * 2. Provision Discovery Request/Response
  420. *
  421. * Fix Service Discovery RX packet buffer pointer.
  422. *
  423. * 03 01 2011 yuche.tsai
  424. * [WCXRP00000501] [Volunteer Patch][MT6620][Driver] No common channel issue when doing GO formation
  425. * Update channel issue when doing GO formation..
  426. *
  427. * 03 01 2011 yuche.tsai
  428. * [WCXRP00000245] 1. Invitation Request/Response.
  429. * 2. Provision Discovery Request/Response
  430. *
  431. * Update Service Discovery Related wlanoid function.
  432. *
  433. * 02 21 2011 yuche.tsai
  434. * [WCXRP00000481] [Volunteer Patch][MT6620][FW] Scan hang under concurrent case.
  435. * Fix all BE issue of WSC or P2P IE.
  436. *
  437. * 02 18 2011 wh.su
  438. * [WCXRP00000471] [MT6620 Wi-Fi][Driver] Add P2P Provison discovery append Config Method attribute at WSC IE
  439. * fixed the wsc config method mapping to driver used config method issue.
  440. *
  441. * 02 18 2011 yuche.tsai
  442. * [WCXRP00000479] [Volunteer Patch][MT6620][Driver] Probe Response of P2P using 11b rate.
  443. * Update basic rate to FW, after P2P is initialed.
  444. *
  445. * 02 18 2011 yuche.tsai
  446. * [WCXRP00000478] [Volunteer Patch][MT6620][Driver] Probe request frame during search phase do not contain P2P wildcard
  447. * SSID.
  448. * Use P2P Wildcard SSID when scan type of P2P_WILDCARD_SSID is set.
  449. *
  450. * 02 18 2011 yuche.tsai
  451. * [WCXRP00000480] [Volunteer Patch][MT6620][Driver] WCS IE format issue
  452. * Fix WSC IE BE format issue.
  453. *
  454. * 02 17 2011 wh.su
  455. * [WCXRP00000471] [MT6620 Wi-Fi][Driver] Add P2P Provison discovery append Config Method attribute at WSC IE
  456. * append the WSC IE config method attribute at provision discovery request.
  457. *
  458. * 02 16 2011 wh.su
  459. * [WCXRP00000448] [MT6620 Wi-Fi][Driver] Fixed WSC IE not send out at probe request
  460. * fixed the probe request send out without WSC IE issue (at P2P).
  461. *
  462. * 02 16 2011 yuche.tsai
  463. * [WCXRP00000431] [Volunteer Patch][MT6620][Driver] Add MLME support for deauthentication under AP(Hot-Spot) mode.
  464. * If two station connected to the Hot-Spot and one disconnect, FW would get into an infinite loop
  465. *
  466. * 02 15 2011 yuche.tsai
  467. * [WCXRP00000431] [Volunteer Patch][MT6620][Driver] Add MLME support for deauthentication under AP(Hot-Spot) mode.
  468. * Fix re-connection issue after RX deauthentication.
  469. *
  470. * 02 15 2011 yuche.tsai
  471. * [WCXRP00000431] [Volunteer Patch][MT6620][Driver] Add MLME support for deauthentication under AP(Hot-Spot) mode.
  472. * Fix conneciton issue after disconnect with AP.
  473. *
  474. * 02 12 2011 yuche.tsai
  475. * [WCXRP00000441] [Volunteer Patch][MT6620][Driver] BoW can not create desired station type when Hot Spot is enabled.
  476. * P2P Create Station Type according to Target BSS capability.
  477. *
  478. * 02 10 2011 yuche.tsai
  479. * [WCXRP00000431] [Volunteer Patch][MT6620][Driver] Add MLME support for deauthentication under AP(Hot-Spot) mode.
  480. * Support Disassoc & Deauthentication for Hot-Spot.
  481. *
  482. * 02 09 2011 yuche.tsai
  483. * [WCXRP00000245] 1. Invitation Request/Response.
  484. * 2. Provision Discovery Request/Response
  485. *
  486. * Add Service Discovery Indication Related code.
  487. *
  488. * 02 09 2011 yuche.tsai
  489. * [WCXRP00000431] [Volunteer Patch][MT6620][Driver] Add MLME support for deauthentication under AP(Hot-Spot) mode.
  490. * Add Support for MLME deauthentication for Hot-Spot.
  491. *
  492. * 02 09 2011 yuche.tsai
  493. * [WCXRP00000429] [Volunteer Patch][MT6620][Driver] Hot Spot Client Limit Issue
  494. * Fix Client Limit Issue.
  495. *
  496. * 02 08 2011 yuche.tsai
  497. * [WCXRP00000419] [Volunteer Patch][MT6620/MT5931][Driver] Provide function of disconnect to target station for AAA
  498. * module.
  499. * Disconnect every station client when disolve on P2P group.
  500. *
  501. * 02 08 2011 yuche.tsai
  502. * [WCXRP00000245] 1. Invitation Request/Response.
  503. * 2. Provision Discovery Request/Response
  504. *
  505. * 1. Fix Service Disocvery Logical issue.
  506. * 2. Fix a NULL pointer access violation issue when sending deauthentication packet to a class error station.
  507. *
  508. * 02 08 2011 yuche.tsai
  509. * [WCXRP00000419] [Volunteer Patch][MT6620/MT5931][Driver] Provide function of disconnect to target station for AAA
  510. * module.
  511. * Workaround of disable P2P network.
  512. *
  513. * 02 08 2011 yuche.tsai
  514. * [WCXRP00000421] [Volunteer Patch][MT6620][Driver] Fix incorrect SSID length Issue
  515. * 1. Fixed SSID wrong length issue.
  516. * 2. Under Hot Spot configuration, there won't be any P2P IE.
  517. * 3. Under Hot Spot configuration, P2P FSM won't get into LISTEN state first.
  518. *
  519. * 01 27 2011 yuche.tsai
  520. * [WCXRP00000399] [Volunteer Patch][MT6620/MT5931][Driver] Fix scan side effect after P2P module separate.
  521. * Modify Start GO flow.
  522. *
  523. * 01 27 2011 yuche.tsai
  524. * [WCXRP00000399] [Volunteer Patch][MT6620/MT5931][Driver] Fix scan side effect after P2P module separate.
  525. * Fix desire phy type set issue.
  526. *
  527. * 01 27 2011 yuche.tsai
  528. * [WCXRP00000399] [Volunteer Patch][MT6620/MT5931][Driver] Fix scan side effect after P2P module separate.
  529. * Add desire phy type set phase I.
  530. *
  531. * 01 26 2011 yuche.tsai
  532. * [WCXRP00000388] [Volunteer Patch][MT6620][Driver/Fw] change Station Type in station record.
  533. * Fix P2P Disconnect Issue.
  534. *
  535. * 01 26 2011 yuche.tsai
  536. * [WCXRP00000245] 1. Invitation Request/Response.
  537. * 2. Provision Discovery Request/Response
  538. *
  539. * Add Service Discovery Function.
  540. *
  541. * 01 26 2011 cm.chang
  542. * [WCXRP00000395] [MT6620 Wi-Fi][Driver][FW] Search STA_REC with additional net type index argument
  543. * .
  544. *
  545. * 01 25 2011 yuche.tsai
  546. * [WCXRP00000388] [Volunteer Patch][MT6620][Driver/Fw] change Station Type in station record.
  547. * Fix compile error when DBG is disabled.
  548. *
  549. * 01 25 2011 yuche.tsai
  550. * [WCXRP00000388] [Volunteer Patch][MT6620][Driver/Fw] change Station Type in station record.
  551. * Change Station Type Definition.
  552. *
  553. * 01 19 2011 yuche.tsai
  554. * [WCXRP00000353] [Volunteer Patch][MT6620][Driver] Desired Non-HT Rate Set update when STA record is created under AP
  555. * Mode.
  556. * Add P2P QoS Support.
  557. *
  558. * 01 19 2011 george.huang
  559. * [WCXRP00000355] [MT6620 Wi-Fi] Set WMM-PS related setting with qualifying AP capability
  560. * Null NOA attribute setting when no related parameters.
  561. *
  562. * 01 14 2011 yuche.tsai
  563. * [WCXRP00000352] [Volunteer Patch][MT6620][Driver] P2P Statsion Record Client List Issue
  564. * Modify AAA flow according to CM's comment.
  565. *
  566. * 01 13 2011 yuche.tsai
  567. * [WCXRP00000353] [Volunteer Patch][MT6620][Driver] Desired Non-HT Rate Set update when STA record is created under AP
  568. * Mode.
  569. * Resolve Channel ZERO issue. (Uninitialized default channel)
  570. *
  571. * 01 13 2011 yuche.tsai
  572. * [WCXRP00000352] [Volunteer Patch][MT6620][Driver] P2P Statsion Record Client List Issue
  573. * Update P2P State Debug Message.
  574. *
  575. * 01 12 2011 yuche.tsai
  576. * [WCXRP00000353] [Volunteer Patch][MT6620][Driver] Desired Non-HT Rate Set update when STA record is created under AP
  577. * Mode.
  578. * Fix bug when allocating message buffer.
  579. *
  580. * 01 12 2011 yuche.tsai
  581. * [WCXRP00000353] [Volunteer Patch][MT6620][Driver] Desired Non-HT Rate Set update when STA record is created under AP
  582. * Mode.
  583. * Update Phy Type Set. When legacy client is connected, it can use 11b rate,
  584. * but if the P2P device is connected, 11b rate is not allowed.
  585. *
  586. * 01 12 2011 yuche.tsai
  587. * [WCXRP00000352] [Volunteer Patch][MT6620][Driver] P2P Statsion Record Client List Issue
  588. * 1. Modify Channel Acquire Time of AP mode from 5s to 1s.
  589. * 2. Call cnmP2pIsPermit() before active P2P network.
  590. * 3. Add channel selection support for AP mode.
  591. *
  592. * 01 12 2011 yuche.tsai
  593. * [WCXRP00000352] [Volunteer Patch][MT6620][Driver] P2P Statsion Record Client List Issue
  594. * Fix Bug of reference to NULL pointer.
  595. *
  596. * 01 12 2011 yuche.tsai
  597. * [WCXRP00000352] [Volunteer Patch][MT6620][Driver] P2P Statsion Record Client List Issue
  598. * Modify some behavior of AP mode.
  599. *
  600. * 01 12 2011 yuche.tsai
  601. * [WCXRP00000352] [Volunteer Patch][MT6620][Driver] P2P Statsion Record Client List Issue
  602. * Fix bug of wrong pointer check.
  603. *
  604. * 01 12 2011 yuche.tsai
  605. * [WCXRP00000352] [Volunteer Patch][MT6620][Driver] P2P Statsion Record Client List Issue
  606. * Fix Compile Error.
  607. *
  608. * 01 11 2011 yuche.tsai
  609. * [WCXRP00000352] [Volunteer Patch][MT6620][Driver] P2P Statsion Record Client List Issue
  610. * Add station record into client list before change it state from STATE_2 to STATE_3.
  611. *
  612. * 01 05 2011 yuche.tsai
  613. * [WCXRP00000345] [MT6620][Volunteer Patch] P2P may issue a SSID specified scan request, but the SSID length is still
  614. * invalid.
  615. * Specify SSID Type when issue a scan request.
  616. *
  617. * 01 05 2011 cp.wu
  618. * [WCXRP00000338] [MT6620 Wi-Fi][Driver] Separate kalMemAlloc into kmalloc and vmalloc implementations to ease
  619. * physically continuous memory demands
  620. * correct typo
  621. *
  622. * 01 05 2011 george.huang
  623. * [WCXRP00000343] [MT6620 Wi-Fi] Add TSF reset path for concurrent operation
  624. * modify NOA update path for preventing assertion false alarm.
  625. *
  626. * 01 04 2011 cp.wu
  627. * [WCXRP00000338] [MT6620 Wi-Fi][Driver] Separate kalMemAlloc into kmalloc and vmalloc implementations to ease
  628. * physically continuous memory demands
  629. * separate kalMemAlloc() into virtually-continuous and physically-continuous type to ease slab system pressure
  630. *
  631. * 01 03 2011 wh.su
  632. * [WCXRP00000326] [MT6620][Wi-Fi][Driver] check in the binary format gl_sec.o.new instead of use change type!!!
  633. * let the p2p ap mode acept a legacy device join.
  634. *
  635. * 12 22 2010 yuche.tsai
  636. * [WCXRP00000245] 1. Invitation Request/Response.
  637. * 2. Provision Discovery Request/Response
  638. *
  639. * Fix Compile Error.
  640. *
  641. * 12 15 2010 yuche.tsai
  642. * [WCXRP00000245] 1. Invitation Request/Response.
  643. * 2. Provision Discovery Request/Response
  644. *
  645. * Refine Connection Flow.
  646. *
  647. * 12 08 2010 yuche.tsai
  648. * [WCXRP00000245] [MT6620][Driver] Invitation & Provision Discovery Feature Check-in
  649. * [WCXRP000000245][MT6620][Driver] Invitation Request Feature Add
  650. *
  651. * 12 08 2010 yuche.tsai
  652. * [WCXRP00000244] [MT6620][Driver] Add station record type for each client when in AP mode.
  653. * Change STA Type under AP mode. We would tell if client is a P2P device or a legacy client by checking the P2P IE in
  654. * assoc req frame.
  655. *
  656. * 12 07 2010 cm.chang
  657. * [WCXRP00000239] MT6620 Wi-Fi][Driver][FW] Merge concurrent branch back to maintrunk
  658. * The order of invoking nicUpdateBss() and rlm functions
  659. *
  660. * 12 02 2010 yuche.tsai
  661. * NULL
  662. * Update P2P Connection Policy for Invitation.
  663. *
  664. * 12 02 2010 yuche.tsai
  665. * NULL
  666. * Update P2P Connection Policy for Invitation & Provision Discovery.
  667. *
  668. * 11 30 2010 yuche.tsai
  669. * NULL
  670. * Invitation & Provision Discovery Indication.
  671. *
  672. * 11 30 2010 yuche.tsai
  673. * NULL
  674. * Update Configure Method indication & selection for Provision Discovery & GO_NEGO_REQ
  675. *
  676. * 11 30 2010 yuche.tsai
  677. * NULL
  678. * Update RCIP value when RX assoc request frame.
  679. *
  680. * 11 29 2010 yuche.tsai
  681. * NULL
  682. * Update P2P related function for INVITATION & PROVISION DISCOVERY.
  683. *
  684. * 11 26 2010 george.huang
  685. * [WCXRP00000152] [MT6620 Wi-Fi] AP mode power saving function
  686. * Update P2P PS for NOA function.
  687. *
  688. * 11 25 2010 yuche.tsai
  689. * NULL
  690. * Update Code for Invitation Related Function.
  691. *
  692. * 11 17 2010 wh.su
  693. * [WCXRP00000164] [MT6620 Wi-Fi][Driver] Support the p2p random SSID[WCXRP00000179] [MT6620 Wi-Fi][FW] Set the Tx lowest
  694. * rate at wlan table for normal operation
  695. * fixed some ASSERT check.
  696. *
  697. * 11 05 2010 wh.su
  698. * [WCXRP00000164] [MT6620 Wi-Fi][Driver] Support the p2p random SSID
  699. * fixed the p2p role code error.
  700. *
  701. * 11 04 2010 wh.su
  702. * [WCXRP00000164] [MT6620 Wi-Fi][Driver] Support the p2p random SSID
  703. * adding the p2p random ssid support.
  704. *
  705. * 10 20 2010 wh.su
  706. * [WCXRP00000124] [MT6620 Wi-Fi] [Driver] Support the dissolve P2P Group
  707. * fixed the ASSERT check error
  708. *
  709. * 10 20 2010 wh.su
  710. * [WCXRP00000124] [MT6620 Wi-Fi] [Driver] Support the dissolve P2P Group
  711. * Add the code to support disconnect p2p group
  712. *
  713. * 10 19 2010 wh.su
  714. * [WCXRP00000085] [MT6620 Wif-Fi] [Driver] update the modified p2p state machine[WCXRP00000102] [MT6620 Wi-Fi] [FW] Add
  715. * a compiling flag and code for support Direct GO at Android
  716. * fixed the compiling error.
  717. *
  718. * 10 14 2010 wh.su
  719. * [WCXRP00000102] [MT6620 Wi-Fi] [FW] Add a compiling flag and code for support Direct GO at Android
  720. * adding a code to support Direct GO with a compiling flag .
  721. *
  722. * 10 08 2010 cp.wu
  723. * [WCXRP00000087] [MT6620 Wi-Fi][Driver] Cannot connect to 5GHz AP, driver will cause FW assert.
  724. * correct erroneous logic: specifying eBand with incompatible eSco
  725. *
  726. * 10 08 2010 wh.su
  727. * [WCXRP00000085] [MT6620 Wif-Fi] [Driver] update the modified p2p state machine
  728. * fixed the compiling error.
  729. *
  730. * 10 08 2010 wh.su
  731. * [WCXRP00000085] [MT6620 Wif-Fi] [Driver] update the modified p2p state machine
  732. * update the frog's new p2p state machine.
  733. *
  734. * 09 10 2010 wh.su
  735. * NULL
  736. * fixed the compiling error at WinXP.
  737. *
  738. * 09 07 2010 yuche.tsai
  739. * NULL
  740. * Reset Common IE Buffer of P2P INFO when scan request is issued.
  741. * If an action frame other than public action frame is received, return direcly.
  742. *
  743. * 09 07 2010 wh.su
  744. * NULL
  745. * adding the code for beacon/probe req/ probe rsp wsc ie at p2p.
  746. *
  747. * 09 06 2010 wh.su
  748. * NULL
  749. * let the p2p can set the privacy bit at beacon and rsn ie at assoc req at key handshake state.
  750. *
  751. * 09 03 2010 kevin.huang
  752. * NULL
  753. * Refine #include sequence and solve recursive/nested #include issue
  754. *
  755. * 08 26 2010 yuche.tsai
  756. * NULL
  757. * Add P2P Connection Abort Event Message handler.
  758. *
  759. * 08 24 2010 cm.chang
  760. * NULL
  761. * Support RLM initail channel of Ad-hoc, P2P and BOW
  762. *
  763. * 08 23 2010 yuche.tsai
  764. * NULL
  765. * 1. Fix Interface Address from GO Nego Req/Rsp is not correct.
  766. * 2. Fix GO mode does not change media state after station connected.
  767. * 3. Fix STA don't response probe request when there is a connection request.
  768. *
  769. * 08 20 2010 cm.chang
  770. * NULL
  771. * Migrate RLM code to host from FW
  772. *
  773. * 08 20 2010 kevin.huang
  774. * NULL
  775. * Modify AAA Module for changing STA STATE 3 at p2p/bowRunEventAAAComplete()
  776. *
  777. * 08 20 2010 yuche.tsai
  778. * NULL
  779. * Add Glue Layer indication.
  780. *
  781. * 08 17 2010 yuche.tsai
  782. * NULL
  783. * Fix compile warning under Linux.
  784. *
  785. * 08 17 2010 yuche.tsai
  786. * NULL
  787. * Fix some P2P FSM bug.
  788. *
  789. * 08 16 2010 yuche.tsai
  790. * NULL
  791. * Add random Interface Address Generation support.
  792. *
  793. * 08 16 2010 yuche.tsai
  794. * NULL
  795. * Fix some P2P FSM bug.
  796. *
  797. * 08 16 2010 yuche.tsai
  798. * NULL
  799. * Update P2P FSM code for GO Nego.
  800. *
  801. * 08 16 2010 kevin.huang
  802. * NULL
  803. * Refine AAA functions
  804. *
  805. * 08 12 2010 kevin.huang
  806. * NULL
  807. * Refine bssProcessProbeRequest() and bssSendBeaconProbeResponse()
  808. *
  809. * 08 12 2010 yuche.tsai
  810. * NULL
  811. * Join complete indication.
  812. *
  813. * 08 11 2010 yuche.tsai
  814. * NULL
  815. * Add two boolean in connection request.
  816. * Based on these two boolean value, P2P FSM should
  817. * decide to do invitation or group formation or start a GO directly.
  818. *
  819. * 08 11 2010 yuche.tsai
  820. * NULL
  821. * Update P2P FSM, currently P2P Device Discovery is verified.
  822. *
  823. * 08 05 2010 yuche.tsai
  824. * NULL
  825. * Update P2P FSM for group formation.
  826. *
  827. * 08 03 2010 george.huang
  828. * NULL
  829. * handle event for updating NOA parameters indicated from FW
  830. *
  831. * 08 03 2010 cp.wu
  832. * NULL
  833. * limit build always needs spin-lock declaration.
  834. *
  835. * 08 02 2010 yuche.tsai
  836. * NULL
  837. * P2P Group Negotiation Code Check in.
  838. *
  839. * 07 26 2010 yuche.tsai
  840. *
  841. * Add P2P FSM code check in.
  842. *
  843. * 07 21 2010 yuche.tsai
  844. *
  845. * Add P2P Scan & Scan Result Parsing & Saving.
  846. *
  847. * 07 19 2010 yuche.tsai
  848. *
  849. * Update P2P FSM.
  850. *
  851. * 07 09 2010 george.huang
  852. *
  853. * [WPD00001556] Migrate PM variables from FW to driver: for composing QoS Info
  854. *
  855. * 07 08 2010 cp.wu
  856. *
  857. * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
  858. *
  859. * 06 21 2010 yuche.tsai
  860. * [WPD00003839][MT6620 5931][P2P] Feature migration
  861. * Fix compile error while enable WIFI_DIRECT support.
  862. *
  863. * 06 21 2010 yuche.tsai
  864. * [WPD00003839][MT6620 5931][P2P] Feature migration
  865. * Update P2P Function call.
  866. *
  867. * 06 17 2010 yuche.tsai
  868. * [WPD00003839][MT6620 5931][P2P] Feature migration
  869. * First draft for migration P2P FSM from FW to Driver.
  870. *
  871. * 04 19 2010 kevin.huang
  872. * [BORA00000714][WIFISYS][New Feature]Beacon Timeout Support
  873. * Add Beacon Timeout Support and will send Null frame to diagnose connection
  874. *
  875. * 03 18 2010 kevin.huang
  876. * [BORA00000663][WIFISYS][New Feature] AdHoc Mode Support
  877. * Rename CFG flag for P2P
  878. *
  879. * 02 26 2010 kevin.huang
  880. * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
  881. * Add code to test P2P GO
  882. *
  883. * 02 23 2010 kevin.huang
  884. * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
  885. * Add Wi-Fi Direct SSID and P2P GO Test Mode
  886. *
  887. * 02 05 2010 kevin.huang
  888. * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
  889. * Modify code due to BAND_24G define was changed
  890. *
  891. * 02 05 2010 kevin.huang
  892. * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
  893. * Revise data structure to share the same BSS_INFO_T for avoiding coding error
  894. *
  895. * 02 04 2010 kevin.huang
  896. * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
  897. * Add AAA Module Support, Revise Net Type to Net Type Index for array lookup
  898. */
  899. /*******************************************************************************
  900. * C O M P I L E R F L A G S
  901. ********************************************************************************
  902. */
  903. /*******************************************************************************
  904. * E X T E R N A L R E F E R E N C E S
  905. ********************************************************************************
  906. */
  907. #include "precomp.h"
  908. #if CFG_ENABLE_WIFI_DIRECT
  909. /*******************************************************************************
  910. * C O N S T A N T S
  911. ********************************************************************************
  912. */
  913. /*******************************************************************************
  914. * D A T A T Y P E S
  915. ********************************************************************************
  916. */
  917. /*******************************************************************************
  918. * P U B L I C D A T A
  919. ********************************************************************************
  920. */
  921. /*******************************************************************************
  922. * P R I V A T E D A T A
  923. ********************************************************************************
  924. */
  925. /*******************************************************************************
  926. * M A C R O S
  927. ********************************************************************************
  928. */
  929. /*******************************************************************************
  930. * F U N C T I O N D E C L A R A T I O N S
  931. ********************************************************************************
  932. */
  933. /*******************************************************************************
  934. * F U N C T I O N S
  935. ********************************************************************************
  936. */
  937. /* /////////////////////////////////MT6630 CODE ///////////////////////////////// */
  938. /* p2pStateXXX : Processing P2P FSM related action.
  939. * p2pFSMXXX : Control P2P FSM flow.
  940. * p2pFuncXXX : Function for doing one thing.
  941. */
  942. VOID p2pFsmInit(IN P_ADAPTER_T prAdapter)
  943. {
  944. P_P2P_FSM_INFO_T prP2pFsmInfo = (P_P2P_FSM_INFO_T) NULL;
  945. P_BSS_INFO_T prP2pBssInfo = (P_BSS_INFO_T) NULL;
  946. do {
  947. ASSERT_BREAK(prAdapter != NULL);
  948. prP2pFsmInfo = prAdapter->rWifiVar.prP2pFsmInfo;
  949. prP2pBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_P2P_INDEX]);
  950. ASSERT_BREAK(prP2pFsmInfo != NULL);
  951. LINK_INITIALIZE(&(prP2pFsmInfo->rMsgEventQueue));
  952. prP2pFsmInfo->eCurrentState = prP2pFsmInfo->ePreviousState = P2P_STATE_IDLE;
  953. prP2pFsmInfo->prTargetBss = NULL;
  954. cnmTimerInitTimer(prAdapter,
  955. &(prP2pFsmInfo->rP2pFsmTimeoutTimer),
  956. (PFN_MGMT_TIMEOUT_FUNC) p2pFsmRunEventFsmTimeout, (ULONG) prP2pFsmInfo);
  957. /* 4 <2> Initiate BSS_INFO_T - common part */
  958. BSS_INFO_INIT(prAdapter, NETWORK_TYPE_P2P_INDEX);
  959. /* 4 <2.1> Initiate BSS_INFO_T - Setup HW ID */
  960. prP2pBssInfo->ucConfigAdHocAPMode = AP_MODE_11G_P2P;
  961. prP2pBssInfo->ucNonHTBasicPhyType = (UINT_8)
  962. rNonHTApModeAttributes[prP2pBssInfo->ucConfigAdHocAPMode].ePhyTypeIndex;
  963. prP2pBssInfo->u2BSSBasicRateSet =
  964. rNonHTApModeAttributes[prP2pBssInfo->ucConfigAdHocAPMode].u2BSSBasicRateSet;
  965. prP2pBssInfo->u2OperationalRateSet =
  966. rNonHTPhyAttributes[prP2pBssInfo->ucNonHTBasicPhyType].u2SupportedRateSet;
  967. rateGetDataRatesFromRateSet(prP2pBssInfo->u2OperationalRateSet,
  968. prP2pBssInfo->u2BSSBasicRateSet,
  969. prP2pBssInfo->aucAllSupportedRates, &prP2pBssInfo->ucAllSupportedRatesLen);
  970. nicTxUpdateBssDefaultRate(prP2pBssInfo);
  971. prP2pBssInfo->prBeacon = cnmMgtPktAlloc(prAdapter,
  972. OFFSET_OF(WLAN_BEACON_FRAME_T, aucInfoElem[0]) + MAX_IE_LENGTH);
  973. if (prP2pBssInfo->prBeacon) {
  974. prP2pBssInfo->prBeacon->eSrc = TX_PACKET_MGMT;
  975. prP2pBssInfo->prBeacon->ucStaRecIndex = 0xFF; /* NULL STA_REC */
  976. prP2pBssInfo->prBeacon->ucNetworkType = NETWORK_TYPE_P2P_INDEX;
  977. } else {
  978. /* Out of memory. */
  979. ASSERT(FALSE);
  980. }
  981. prP2pBssInfo->eCurrentOPMode = OP_MODE_NUM;
  982. prP2pBssInfo->rPmProfSetupInfo.ucBmpDeliveryAC = PM_UAPSD_ALL;
  983. prP2pBssInfo->rPmProfSetupInfo.ucBmpTriggerAC = PM_UAPSD_ALL;
  984. prP2pBssInfo->rPmProfSetupInfo.ucUapsdSp = WMM_MAX_SP_LENGTH_2;
  985. prP2pBssInfo->ucPrimaryChannel = P2P_DEFAULT_LISTEN_CHANNEL;
  986. prP2pBssInfo->eBand = BAND_2G4;
  987. prP2pBssInfo->eBssSCO = CHNL_EXT_SCN;
  988. if (IS_FEATURE_ENABLED(prAdapter->rWifiVar.ucQoS))
  989. prP2pBssInfo->fgIsQBSS = TRUE;
  990. else
  991. prP2pBssInfo->fgIsQBSS = FALSE;
  992. SET_NET_PWR_STATE_IDLE(prAdapter, NETWORK_TYPE_P2P_INDEX);
  993. /* wlanBindBssIdxToNetInterface(prAdapter->prGlueInfo, NET_DEV_P2P_IDX, prP2pBssInfo->ucBssIndex); */
  994. p2pFsmStateTransition(prAdapter, prP2pFsmInfo, P2P_STATE_IDLE);
  995. } while (FALSE);
  996. } /* p2pFsmInit */
  997. /*----------------------------------------------------------------------------*/
  998. /*!
  999. * @brief The function is used to uninitialize the value in P2P_FSM_INFO_T for
  1000. * P2P FSM operation
  1001. *
  1002. * @param (none)
  1003. *
  1004. * @return (none)
  1005. */
  1006. /*----------------------------------------------------------------------------*/
  1007. VOID p2pFsmUninit(IN P_ADAPTER_T prAdapter)
  1008. {
  1009. P_P2P_FSM_INFO_T prP2pFsmInfo = (P_P2P_FSM_INFO_T) NULL;
  1010. P_BSS_INFO_T prP2pBssInfo = (P_BSS_INFO_T) NULL;
  1011. do {
  1012. ASSERT_BREAK(prAdapter != NULL);
  1013. DEBUGFUNC("p2pFsmUninit()");
  1014. DBGLOG(P2P, INFO, "->p2pFsmUninit()\n");
  1015. prP2pFsmInfo = prAdapter->rWifiVar.prP2pFsmInfo;
  1016. prP2pBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_P2P_INDEX]);
  1017. p2pFuncSwitchOPMode(prAdapter, prP2pBssInfo, OP_MODE_P2P_DEVICE, TRUE);
  1018. p2pFsmRunEventAbort(prAdapter, prP2pFsmInfo);
  1019. p2pStateAbort_IDLE(prAdapter, prP2pFsmInfo, P2P_STATE_NUM);
  1020. UNSET_NET_ACTIVE(prAdapter, NETWORK_TYPE_P2P_INDEX);
  1021. wlanAcquirePowerControl(prAdapter);
  1022. /* Release all pending CMD queue. */
  1023. DBGLOG(P2P, TRACE,
  1024. "p2pFsmUninit: wlanProcessCommandQueue, num of element:%d\n",
  1025. prAdapter->prGlueInfo->rCmdQueue.u4NumElem);
  1026. wlanProcessCommandQueue(prAdapter, &prAdapter->prGlueInfo->rCmdQueue);
  1027. wlanReleasePowerControl(prAdapter);
  1028. /* Release pending mgmt frame,
  1029. * mgmt frame may be pending by CMD without resource.
  1030. */
  1031. kalClearMgmtFramesByBssIdx(prAdapter->prGlueInfo, NETWORK_TYPE_P2P_INDEX);
  1032. /* Clear PendingCmdQue */
  1033. wlanReleasePendingCMDbyBssIdx(prAdapter, NETWORK_TYPE_P2P_INDEX);
  1034. if (prP2pBssInfo->prBeacon) {
  1035. cnmMgtPktFree(prAdapter, prP2pBssInfo->prBeacon);
  1036. prP2pBssInfo->prBeacon = NULL;
  1037. }
  1038. } while (FALSE);
  1039. } /* end of p2pFsmUninit() */
  1040. VOID p2pFsmStateTransition(IN P_ADAPTER_T prAdapter, IN P_P2P_FSM_INFO_T prP2pFsmInfo, IN ENUM_P2P_STATE_T eNextState)
  1041. {
  1042. BOOLEAN fgIsTransOut = (BOOLEAN) FALSE;
  1043. P_BSS_INFO_T prP2pBssInfo = (P_BSS_INFO_T) NULL;
  1044. P_P2P_SPECIFIC_BSS_INFO_T prP2pSpecificBssInfo = (P_P2P_SPECIFIC_BSS_INFO_T) NULL;
  1045. do {
  1046. ASSERT_BREAK((prAdapter != NULL) && (prP2pFsmInfo != NULL));
  1047. prP2pBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_P2P_INDEX]);
  1048. prP2pSpecificBssInfo = prAdapter->rWifiVar.prP2pSpecificBssInfo;
  1049. if (!IS_BSS_ACTIVE(prP2pBssInfo)) {
  1050. if (!cnmP2PIsPermitted(prAdapter))
  1051. return;
  1052. SET_NET_ACTIVE(prAdapter, NETWORK_TYPE_P2P_INDEX);
  1053. nicActivateNetwork(prAdapter, NETWORK_TYPE_P2P_INDEX);
  1054. }
  1055. fgIsTransOut = fgIsTransOut ? FALSE : TRUE;
  1056. if (!fgIsTransOut) {
  1057. DBGLOG(P2P, STATE, "TRANSITION: [%s] -> [%s]\n",
  1058. apucDebugP2pState[prP2pFsmInfo->eCurrentState],
  1059. apucDebugP2pState[eNextState];
  1060. /* Transition into current state. */
  1061. prP2pFsmInfo->ePreviousState = prP2pFsmInfo->eCurrentState;
  1062. prP2pFsmInfo->eCurrentState = eNextState;
  1063. }
  1064. switch (prP2pFsmInfo->eCurrentState) {
  1065. case P2P_STATE_IDLE:
  1066. if (fgIsTransOut)
  1067. p2pStateAbort_IDLE(prAdapter, prP2pFsmInfo, eNextState);
  1068. else
  1069. fgIsTransOut = p2pStateInit_IDLE(prAdapter, prP2pFsmInfo, prP2pBssInfo, &eNextState);
  1070. break;
  1071. case P2P_STATE_SCAN:
  1072. if (fgIsTransOut) {
  1073. /* Scan done / scan canceled. */
  1074. /* p2pStateAbort_SCAN(prAdapter, prP2pFsmInfo, eNextState); */
  1075. } else {
  1076. /* Initial scan request. */
  1077. /* p2pStateInit_SCAN(prAdapter, prP2pFsmInfo); */
  1078. }
  1079. break;
  1080. case P2P_STATE_AP_CHANNEL_DETECT:
  1081. if (fgIsTransOut) {
  1082. /* Scan done */
  1083. /* Get sparse channel result. */
  1084. p2pStateAbort_AP_CHANNEL_DETECT(prAdapter,
  1085. prP2pFsmInfo, prP2pSpecificBssInfo, eNextState);
  1086. } else {
  1087. /* Initial passive scan request. */
  1088. /* p2pStateInit_AP_CHANNEL_DETECT(prAdapter, prP2pFsmInfo); */
  1089. }
  1090. break;
  1091. case P2P_STATE_REQING_CHANNEL:
  1092. if (fgIsTransOut) {
  1093. /* Channel on hand / Channel canceled. */
  1094. p2pStateAbort_REQING_CHANNEL(prAdapter, prP2pFsmInfo, eNextState);
  1095. } else {
  1096. /* Initial channel request. */
  1097. p2pFuncAcquireCh(prAdapter, &(prP2pFsmInfo->rChnlReqInfo));
  1098. }
  1099. break;
  1100. case P2P_STATE_CHNL_ON_HAND:
  1101. if (fgIsTransOut) {
  1102. p2pStateAbort_CHNL_ON_HAND(prAdapter, prP2pFsmInfo, prP2pBssInfo, eNextState);
  1103. } else {
  1104. /* Initial channel ready. */
  1105. /* Send channel ready event. */
  1106. /* Start a FSM timer. */
  1107. p2pStateInit_CHNL_ON_HAND(prAdapter, prP2pBssInfo, prP2pFsmInfo);
  1108. }
  1109. break;
  1110. case P2P_STATE_GC_JOIN:
  1111. if (fgIsTransOut) {
  1112. /* Join complete / join canceled. */
  1113. p2pStateAbort_GC_JOIN(prAdapter, prP2pFsmInfo, &(prP2pFsmInfo->rJoinInfo), eNextState);
  1114. } else {
  1115. ASSERT(prP2pFsmInfo->prTargetBss != NULL);
  1116. /* Send request to SAA module. */
  1117. p2pStateInit_GC_JOIN(prAdapter,
  1118. prP2pFsmInfo,
  1119. prP2pBssInfo,
  1120. &(prP2pFsmInfo->rJoinInfo), prP2pFsmInfo->prTargetBss);
  1121. }
  1122. break;
  1123. default:
  1124. break;
  1125. }
  1126. } while (fgIsTransOut);
  1127. } /* p2pFsmStateTransition */
  1128. #if 0
  1129. VOID p2pFsmRunEventChannelRequest(IN P_ADAPTER_T prAdapter, IN P_MSG_HDR_T prMsgHdr)
  1130. {
  1131. P_P2P_CHNL_REQ_INFO_T prChnlReqInfo = (P_P2P_CHNL_REQ_INFO_T) NULL;
  1132. P_MSG_P2P_CHNL_REQUEST_T prP2pChnlReqMsg = (P_MSG_P2P_CHNL_REQUEST_T) NULL;
  1133. P_P2P_FSM_INFO_T prP2pFsmInfo = (P_P2P_FSM_INFO_T) NULL;
  1134. ENUM_P2P_STATE_T eNextState = P2P_STATE_NUM;
  1135. do {
  1136. ASSERT_BREAK((prAdapter != NULL) && (prMsgHdr != NULL));
  1137. prP2pChnlReqMsg = (P_MSG_P2P_CHNL_REQUEST_T) prMsgHdr;
  1138. prP2pFsmInfo = prAdapter->rWifiVar.prP2pFsmInfo;
  1139. if (prP2pFsmInfo == NULL)
  1140. break;
  1141. prChnlReqInfo = &(prP2pFsmInfo->rChnlReqInfo);
  1142. DBGLOG(P2P, TRACE, "p2pFsmRunEventChannelRequest\n");
  1143. /* Special case of time renewing for same frequency. */
  1144. if ((prP2pFsmInfo->eCurrentState == P2P_STATE_CHNL_ON_HAND) &&
  1145. (prChnlReqInfo->ucReqChnlNum == prP2pChnlReqMsg->rChannelInfo.ucChannelNum) &&
  1146. (prChnlReqInfo->eBand == prP2pChnlReqMsg->rChannelInfo.eBand) &&
  1147. (prChnlReqInfo->eChnlSco == prP2pChnlReqMsg->eChnlSco)) {
  1148. ASSERT(prChnlReqInfo->fgIsChannelRequested == TRUE);
  1149. ASSERT(prChnlReqInfo->eChannelReqType == CHANNEL_REQ_TYPE_REMAIN_ON_CHANNEL);
  1150. prChnlReqInfo->u8Cookie = prP2pChnlReqMsg->u8Cookie;
  1151. prChnlReqInfo->u4MaxInterval = prP2pChnlReqMsg->u4Duration;
  1152. /* Re-enter the state. */
  1153. eNextState = P2P_STATE_CHNL_ON_HAND;
  1154. } else {
  1155. /* Make sure the state is in IDLE state. */
  1156. p2pFsmRunEventAbort(prAdapter, prP2pFsmInfo);
  1157. prChnlReqInfo->u8Cookie = prP2pChnlReqMsg->u8Cookie; /* Cookie can only be assign after
  1158. * abort.(for indication) */
  1159. prChnlReqInfo->ucReqChnlNum = prP2pChnlReqMsg->rChannelInfo.ucChannelNum;
  1160. prChnlReqInfo->eBand = prP2pChnlReqMsg->rChannelInfo.eBand;
  1161. prChnlReqInfo->eChnlSco = prP2pChnlReqMsg->eChnlSco;
  1162. prChnlReqInfo->u4MaxInterval = prP2pChnlReqMsg->u4Duration;
  1163. prChnlReqInfo->eChannelReqType = CHANNEL_REQ_TYPE_REMAIN_ON_CHANNEL;
  1164. eNextState = P2P_STATE_REQING_CHANNEL;
  1165. }
  1166. p2pFsmStateTransition(prAdapter, prP2pFsmInfo, eNextState);
  1167. } while (FALSE);
  1168. if (prMsgHdr)
  1169. cnmMemFree(prAdapter, prMsgHdr);
  1170. } /* p2pFsmRunEventChannelRequest */
  1171. VOID p2pFsmRunEventChannelAbort(IN P_ADAPTER_T prAdapter, IN P_MSG_HDR_T prMsgHdr)
  1172. {
  1173. P_P2P_FSM_INFO_T prP2pFsmInfo = (P_P2P_FSM_INFO_T) NULL;
  1174. P_MSG_P2P_CHNL_ABORT_T prChnlAbortMsg = (P_MSG_P2P_CHNL_ABORT_T) NULL;
  1175. P_P2P_CHNL_REQ_INFO_T prChnlReqInfo = (P_P2P_CHNL_REQ_INFO_T) NULL;
  1176. do {
  1177. ASSERT_BREAK((prAdapter != NULL) && (prMsgHdr != NULL));
  1178. prChnlAbortMsg = (P_MSG_P2P_CHNL_ABORT_T) prMsgHdr;
  1179. prP2pFsmInfo = prAdapter->rWifiVar.prP2pFsmInfo;
  1180. if (prP2pFsmInfo == NULL)
  1181. break;
  1182. prChnlReqInfo = &prP2pFsmInfo->rChnlReqInfo;
  1183. DBGLOG(P2P, TRACE, "p2pFsmRunEventChannelAbort\n");
  1184. if ((prChnlAbortMsg->u8Cookie == prChnlReqInfo->u8Cookie) && (prChnlReqInfo->fgIsChannelRequested)) {
  1185. ASSERT((prP2pFsmInfo->eCurrentState == P2P_STATE_REQING_CHANNEL ||
  1186. (prP2pFsmInfo->eCurrentState == P2P_STATE_CHNL_ON_HAND)));
  1187. p2pFsmStateTransition(prAdapter, prP2pFsmInfo, P2P_STATE_IDLE);
  1188. }
  1189. } while (FALSE);
  1190. if (prMsgHdr)
  1191. cnmMemFree(prAdapter, prMsgHdr);
  1192. } /* p2pFsmRunEventChannelAbort */
  1193. #endif
  1194. VOID p2pFsmRunEventScanRequest(IN P_ADAPTER_T prAdapter, IN P_MSG_HDR_T prMsgHdr)
  1195. {
  1196. P_P2P_FSM_INFO_T prP2pFsmInfo = (P_P2P_FSM_INFO_T) NULL;
  1197. P_MSG_P2P_SCAN_REQUEST_T prP2pScanReqMsg = (P_MSG_P2P_SCAN_REQUEST_T) NULL;
  1198. P_P2P_SCAN_REQ_INFO_T prScanReqInfo = (P_P2P_SCAN_REQ_INFO_T) NULL;
  1199. UINT_32 u4ChnlListSize = 0;
  1200. do {
  1201. ASSERT_BREAK((prAdapter != NULL) && (prMsgHdr != NULL));
  1202. prP2pFsmInfo = prAdapter->rWifiVar.prP2pFsmInfo;
  1203. if (prP2pFsmInfo == NULL)
  1204. break;
  1205. prP2pScanReqMsg = (P_MSG_P2P_SCAN_REQUEST_T) prMsgHdr;
  1206. prScanReqInfo = &(prP2pFsmInfo->rScanReqInfo);
  1207. DBGLOG(P2P, TRACE, "p2pFsmRunEventScanRequest\n");
  1208. /* Make sure the state is in IDLE state. */
  1209. p2pFsmRunEventAbort(prAdapter, prP2pFsmInfo);
  1210. ASSERT(prScanReqInfo->fgIsScanRequest == FALSE);
  1211. prScanReqInfo->fgIsAbort = TRUE;
  1212. prScanReqInfo->eScanType = SCAN_TYPE_ACTIVE_SCAN;
  1213. prScanReqInfo->eChannelSet = SCAN_CHANNEL_SPECIFIED;
  1214. /* Channel List */
  1215. prScanReqInfo->ucNumChannelList = prP2pScanReqMsg->u4NumChannel;
  1216. DBGLOG(P2P, TRACE, "Scan Request Channel List Number: %d\n", prScanReqInfo->ucNumChannelList);
  1217. if (prScanReqInfo->ucNumChannelList > MAXIMUM_OPERATION_CHANNEL_LIST) {
  1218. DBGLOG(P2P, TRACE, "Channel List Number Overloaded: %d, change to: %d\n",
  1219. prScanReqInfo->ucNumChannelList, MAXIMUM_OPERATION_CHANNEL_LIST;
  1220. prScanReqInfo->ucNumChannelList = MAXIMUM_OPERATION_CHANNEL_LIST;
  1221. }
  1222. u4ChnlListSize = sizeof(RF_CHANNEL_INFO_T) * prScanReqInfo->ucNumChannelList;
  1223. kalMemCopy(prScanReqInfo->arScanChannelList, prP2pScanReqMsg->arChannelListInfo, u4ChnlListSize);
  1224. /* TODO: I only take the first SSID. Multiple SSID may be needed in the future. */
  1225. /* SSID */
  1226. #if 0
  1227. if (prP2pScanReqMsg->i4SsidNum >= 1)
  1228. kalMemCopy(&(prScanReqInfo->rSsidStruct), prP2pScanReqMsg->prSSID, sizeof(P2P_SSID_STRUCT_T));
  1229. else
  1230. prScanReqInfo->rSsidStruct.ucSsidLen = 0;
  1231. #endif
  1232. /* IE Buffer */
  1233. kalMemCopy(prScanReqInfo->aucIEBuf, prP2pScanReqMsg->pucIEBuf, prP2pScanReqMsg->u4IELen);
  1234. prScanReqInfo->u4BufLength = prP2pScanReqMsg->u4IELen;
  1235. p2pFsmStateTransition(prAdapter, prP2pFsmInfo, P2P_STATE_SCAN);
  1236. } while (FALSE);
  1237. if (prMsgHdr)
  1238. cnmMemFree(prAdapter, prMsgHdr);
  1239. } /* p2pFsmRunEventScanRequest */
  1240. VOID p2pFsmRunEventScanAbort(IN P_ADAPTER_T prAdapter, IN P_MSG_HDR_T prMsgHdr)
  1241. {
  1242. P_P2P_FSM_INFO_T prP2pFsmInfo = (P_P2P_FSM_INFO_T) NULL;
  1243. do {
  1244. ASSERT_BREAK(prAdapter != NULL);
  1245. DBGLOG(P2P, TRACE, "p2pFsmRunEventScanAbort\n");
  1246. prP2pFsmInfo = prAdapter->rWifiVar.prP2pFsmInfo;
  1247. if (prP2pFsmInfo->eCurrentState == P2P_STATE_SCAN) {
  1248. P_P2P_SCAN_REQ_INFO_T prScanReqInfo = &(prP2pFsmInfo->rScanReqInfo);
  1249. prScanReqInfo->fgIsAbort = TRUE;
  1250. p2pFsmStateTransition(prAdapter, prP2pFsmInfo, P2P_STATE_IDLE);
  1251. }
  1252. } while (FALSE);
  1253. if (prMsgHdr)
  1254. cnmMemFree(prAdapter, prMsgHdr);
  1255. } /* p2pFsmRunEventScanAbort */
  1256. VOID p2pFsmRunEventAbort(IN P_ADAPTER_T prAdapter, IN P_P2P_FSM_INFO_T prP2pFsmInfo)
  1257. {
  1258. P_BSS_INFO_T prP2pBssInfo = (P_BSS_INFO_T) NULL;
  1259. do {
  1260. ASSERT_BREAK((prAdapter != NULL) && (prP2pFsmInfo != NULL));
  1261. prP2pBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_P2P_INDEX]);
  1262. DBGLOG(P2P, TRACE, "p2pFsmRunEventAbort\n");
  1263. if (prP2pFsmInfo->eCurrentState != P2P_STATE_IDLE) {
  1264. if (prP2pFsmInfo->eCurrentState == P2P_STATE_SCAN) {
  1265. P_P2P_SCAN_REQ_INFO_T prScanReqInfo = &(prP2pFsmInfo->rScanReqInfo);
  1266. prScanReqInfo->fgIsAbort = TRUE;
  1267. } else if (prP2pFsmInfo->eCurrentState == P2P_STATE_REQING_CHANNEL) {
  1268. /* 2012/08/06: frog
  1269. * Prevent Start GO.
  1270. */
  1271. prP2pBssInfo->eIntendOPMode = OP_MODE_NUM;
  1272. }
  1273. /* For other state, is there any special action that should be take before leaving? */
  1274. p2pFsmStateTransition(prAdapter, prP2pFsmInfo, P2P_STATE_IDLE);
  1275. } else {
  1276. /* P2P State IDLE. */
  1277. P_P2P_CHNL_REQ_INFO_T prChnlReqInfo = &(prP2pFsmInfo->rChnlReqInfo);
  1278. if (prChnlReqInfo->fgIsChannelRequested)
  1279. p2pFuncReleaseCh(prAdapter, prChnlReqInfo);
  1280. cnmTimerStopTimer(prAdapter, &(prP2pFsmInfo->rP2pFsmTimeoutTimer));
  1281. }
  1282. } while (FALSE);
  1283. } /* p2pFsmRunEventAbort */
  1284. /*----------------------------------------------------------------------------*/
  1285. /*!
  1286. * \brief This function is used to handle FSM Timeout.
  1287. *
  1288. * \param[in] prAdapter Pointer of ADAPTER_T
  1289. *
  1290. * \return none
  1291. */
  1292. /*----------------------------------------------------------------------------*/
  1293. VOID p2pFsmRunEventFsmTimeout(IN P_ADAPTER_T prAdapter, IN ULONG ulParamPtr)
  1294. {
  1295. P_P2P_FSM_INFO_T prP2pFsmInfo = (P_P2P_FSM_INFO_T) ulParamPtr;
  1296. do {
  1297. ASSERT_BREAK((prAdapter != NULL) && (prP2pFsmInfo != NULL));
  1298. DBGLOG(P2P, TRACE, "P2P FSM Timeout Event\n");
  1299. switch (prP2pFsmInfo->eCurrentState) {
  1300. case P2P_STATE_IDLE:
  1301. {
  1302. P_P2P_CHNL_REQ_INFO_T prChnlReqInfo = &prP2pFsmInfo->rChnlReqInfo;
  1303. if (prChnlReqInfo->fgIsChannelRequested) {
  1304. p2pFuncReleaseCh(prAdapter, prChnlReqInfo);
  1305. } else if (IS_NET_PWR_STATE_IDLE(prAdapter, NETWORK_TYPE_P2P_INDEX)) {
  1306. UNSET_NET_ACTIVE(prAdapter, NETWORK_TYPE_P2P_INDEX);
  1307. nicDeactivateNetwork(prAdapter, NETWORK_TYPE_P2P_INDEX);
  1308. }
  1309. }
  1310. break;
  1311. /* case P2P_STATE_SCAN: */
  1312. /* break; */
  1313. /* case P2P_STATE_AP_CHANNEL_DETECT: */
  1314. /* break; */
  1315. /* case P2P_STATE_REQING_CHANNEL: */
  1316. /* break; */
  1317. case P2P_STATE_CHNL_ON_HAND:
  1318. {
  1319. p2pFsmStateTransition(prAdapter, prP2pFsmInfo, P2P_STATE_IDLE);
  1320. }
  1321. break;
  1322. /* case P2P_STATE_GC_JOIN: */
  1323. /* break; */
  1324. default:
  1325. break;
  1326. }
  1327. } while (FALSE);
  1328. } /* p2pFsmRunEventFsmTimeout */
  1329. VOID p2pFsmRunEventStartAP(IN P_ADAPTER_T prAdapter, IN P_MSG_HDR_T prMsgHdr)
  1330. {
  1331. P_P2P_FSM_INFO_T prP2pFsmInfo = (P_P2P_FSM_INFO_T) NULL;
  1332. P_BSS_INFO_T prP2pBssInfo = (P_BSS_INFO_T) NULL;
  1333. P_MSG_P2P_START_AP_T prP2pStartAPMsg = (P_MSG_P2P_START_AP_T) NULL;
  1334. P_P2P_SPECIFIC_BSS_INFO_T prP2pSpecificBssInfo = (P_P2P_SPECIFIC_BSS_INFO_T) NULL;
  1335. do {
  1336. ASSERT_BREAK((prAdapter != NULL) && (prMsgHdr != NULL));
  1337. DBGLOG(P2P, TRACE, "p2pFsmRunEventStartAP\n");
  1338. prP2pFsmInfo = prAdapter->rWifiVar.prP2pFsmInfo;
  1339. if (prP2pFsmInfo == NULL)
  1340. break;
  1341. prP2pBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_P2P_INDEX]);
  1342. prP2pStartAPMsg = (P_MSG_P2P_START_AP_T) prMsgHdr;
  1343. prP2pSpecificBssInfo = prAdapter->rWifiVar.prP2pSpecificBssInfo;
  1344. if (prP2pStartAPMsg->u4BcnInterval) {
  1345. DBGLOG(P2P, TRACE, "Beacon interval updated to :%ld\n", prP2pStartAPMsg->u4BcnInterval);
  1346. prP2pBssInfo->u2BeaconInterval = (UINT_16) prP2pStartAPMsg->u4BcnInterval;
  1347. } else if (prP2pBssInfo->u2BeaconInterval == 0) {
  1348. prP2pBssInfo->u2BeaconInterval = DOT11_BEACON_PERIOD_DEFAULT;
  1349. }
  1350. if (prP2pStartAPMsg->u4DtimPeriod) {
  1351. DBGLOG(P2P, TRACE, "DTIM interval updated to :%ld\n", prP2pStartAPMsg->u4DtimPeriod);
  1352. prP2pBssInfo->ucDTIMPeriod = (UINT_8) prP2pStartAPMsg->u4DtimPeriod;
  1353. } else if (prP2pBssInfo->ucDTIMPeriod == 0) {
  1354. prP2pBssInfo->ucDTIMPeriod = DOT11_DTIM_PERIOD_DEFAULT;
  1355. }
  1356. if (prP2pStartAPMsg->u2SsidLen != 0) {
  1357. kalMemCopy(prP2pBssInfo->aucSSID, prP2pStartAPMsg->aucSsid, prP2pStartAPMsg->u2SsidLen);
  1358. kalMemCopy(prP2pSpecificBssInfo->aucGroupSsid, prP2pStartAPMsg->aucSsid,
  1359. prP2pStartAPMsg->u2SsidLen);
  1360. prP2pBssInfo->ucSSIDLen = prP2pSpecificBssInfo->u2GroupSsidLen = prP2pStartAPMsg->u2SsidLen;
  1361. }
  1362. prP2pBssInfo->eHiddenSsidType = prP2pStartAPMsg->ucHiddenSsidType;
  1363. /* TODO: JB */
  1364. /* Privacy & inactive timeout. */
  1365. if ((prP2pBssInfo->eCurrentOPMode != OP_MODE_ACCESS_POINT) ||
  1366. (prP2pBssInfo->eIntendOPMode != OP_MODE_NUM)) {
  1367. UINT_8 ucPreferedChnl = 0;
  1368. ENUM_BAND_T eBand = BAND_NULL;
  1369. ENUM_CHNL_EXT_T eSco = CHNL_EXT_SCN;
  1370. ENUM_P2P_STATE_T eNextState = P2P_STATE_SCAN;
  1371. P_P2P_CONNECTION_SETTINGS_T prP2pConnSettings = prAdapter->rWifiVar.prP2PConnSettings;
  1372. if (prP2pFsmInfo->eCurrentState != P2P_STATE_SCAN &&
  1373. prP2pFsmInfo->eCurrentState != P2P_STATE_IDLE) {
  1374. /* Make sure the state is in IDLE state. */
  1375. p2pFsmRunEventAbort(prAdapter, prP2pFsmInfo);
  1376. }
  1377. /* 20120118: Moved to p2pFuncSwitchOPMode(). */
  1378. /* SET_NET_ACTIVE(prAdapter, NETWORK_TYPE_P2P_INDEX); */
  1379. /* Leave IDLE state. */
  1380. SET_NET_PWR_STATE_ACTIVE(prAdapter, NETWORK_TYPE_P2P_INDEX);
  1381. /* sync with firmware */
  1382. /* DBGLOG(P2P, INFO, ("Activate P2P Network.\n")); */
  1383. /* nicActivateNetwork(prAdapter, NETWORK_TYPE_P2P_INDEX); */
  1384. /* Key to trigger P2P FSM to allocate channel for AP mode. */
  1385. prP2pBssInfo->eIntendOPMode = OP_MODE_ACCESS_POINT;
  1386. /* Sparse Channel to decide which channel to use. */
  1387. if ((cnmPreferredChannel(prAdapter, &eBand, &ucPreferedChnl, &eSco) == FALSE)
  1388. && (prP2pConnSettings->ucOperatingChnl == 0)) {
  1389. /* Sparse Channel Detection using passive mode. */
  1390. eNextState = P2P_STATE_AP_CHANNEL_DETECT;
  1391. } else {
  1392. P_P2P_SPECIFIC_BSS_INFO_T prP2pSpecificBssInfo =
  1393. prAdapter->rWifiVar.prP2pSpecificBssInfo;
  1394. P_P2P_CHNL_REQ_INFO_T prChnlReqInfo = &prP2pFsmInfo->rChnlReqInfo;
  1395. #if 1
  1396. /* 2012-01-27: frog - Channel set from upper layer is the first priority. */
  1397. /* Because the channel & beacon is decided by p2p_supplicant. */
  1398. if (prP2pConnSettings->ucOperatingChnl != 0) {
  1399. prP2pSpecificBssInfo->ucPreferredChannel = prP2pConnSettings->ucOperatingChnl;
  1400. prP2pSpecificBssInfo->eRfBand = prP2pConnSettings->eBand;
  1401. } else {
  1402. ASSERT(ucPreferedChnl != 0);
  1403. prP2pSpecificBssInfo->ucPreferredChannel = ucPreferedChnl;
  1404. prP2pSpecificBssInfo->eRfBand = eBand;
  1405. }
  1406. #else
  1407. if (ucPreferedChnl) {
  1408. prP2pSpecificBssInfo->ucPreferredChannel = ucPreferedChnl;
  1409. prP2pSpecificBssInfo->eRfBand = eBand;
  1410. } else {
  1411. ASSERT(prP2pConnSettings->ucOperatingChnl != 0);
  1412. prP2pSpecificBssInfo->ucPreferredChannel = prP2pConnSettings->ucOperatingChnl;
  1413. prP2pSpecificBssInfo->eRfBand = prP2pConnSettings->eBand;
  1414. }
  1415. #endif
  1416. prChnlReqInfo->ucReqChnlNum = prP2pSpecificBssInfo->ucPreferredChannel;
  1417. prChnlReqInfo->eBand = prP2pSpecificBssInfo->eRfBand;
  1418. prChnlReqInfo->eChannelReqType = CHANNEL_REQ_TYPE_GO_START_BSS;
  1419. }
  1420. /* If channel is specified, use active scan to shorten the scan time. */
  1421. p2pFsmStateTransition(prAdapter, prAdapter->rWifiVar.prP2pFsmInfo, eNextState);
  1422. }
  1423. } while (FALSE);
  1424. if (prMsgHdr)
  1425. cnmMemFree(prAdapter, prMsgHdr);
  1426. } /* p2pFsmRunEventStartAP */
  1427. VOID p2pFsmRunEventStopAP(IN P_ADAPTER_T prAdapter, IN P_MSG_HDR_T prMsgHdr)
  1428. {
  1429. P_BSS_INFO_T prP2pBssInfo = (P_BSS_INFO_T) NULL;
  1430. do {
  1431. ASSERT_BREAK((prAdapter != NULL));
  1432. prP2pBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_P2P_INDEX]);
  1433. DBGLOG(P2P, TRACE, "p2pFsmRunEventStopAP\n");
  1434. if ((prP2pBssInfo->eCurrentOPMode == OP_MODE_ACCESS_POINT)
  1435. && (prP2pBssInfo->eIntendOPMode == OP_MODE_NUM)) {
  1436. /* AP is created, Beacon Update. */
  1437. p2pFuncDissolve(prAdapter, prP2pBssInfo, TRUE, REASON_CODE_DEAUTH_LEAVING_BSS);
  1438. DBGLOG(P2P, TRACE, "Stop Beaconing\n");
  1439. nicPmIndicateBssAbort(prAdapter, NETWORK_TYPE_P2P_INDEX);
  1440. /* Reset RLM related field of BSSINFO. */
  1441. rlmBssAborted(prAdapter, prP2pBssInfo);
  1442. }
  1443. /* 20120118: Moved to p2pFuncSwitchOPMode(). */
  1444. /* UNSET_NET_ACTIVE(prAdapter, NETWORK_TYPE_P2P_INDEX); */
  1445. /* Enter IDLE state. */
  1446. SET_NET_PWR_STATE_IDLE(prAdapter, NETWORK_TYPE_P2P_INDEX);
  1447. DBGLOG(P2P, INFO, "Re activate P2P Network.\n");
  1448. nicDeactivateNetwork(prAdapter, NETWORK_TYPE_P2P_INDEX);
  1449. nicActivateNetwork(prAdapter, NETWORK_TYPE_P2P_INDEX);
  1450. p2pFsmRunEventAbort(prAdapter, prAdapter->rWifiVar.prP2pFsmInfo);
  1451. /* p2pFsmStateTransition(prAdapter, prAdapter->rWifiVar.prP2pFsmInfo, P2P_STATE_IDLE); */
  1452. } while (FALSE);
  1453. if (prMsgHdr)
  1454. cnmMemFree(prAdapter, prMsgHdr);
  1455. } /* p2pFsmRunEventStopAP */
  1456. VOID p2pFsmRunEventConnectionRequest(IN P_ADAPTER_T prAdapter, IN P_MSG_HDR_T prMsgHdr)
  1457. {
  1458. P_BSS_INFO_T prP2pBssInfo = (P_BSS_INFO_T) NULL;
  1459. P_P2P_FSM_INFO_T prP2pFsmInfo = (P_P2P_FSM_INFO_T) NULL;
  1460. P_P2P_CHNL_REQ_INFO_T prChnlReqInfo = (P_P2P_CHNL_REQ_INFO_T) NULL;
  1461. P_MSG_P2P_CONNECTION_REQUEST_T prConnReqMsg = (P_MSG_P2P_CONNECTION_REQUEST_T) NULL;
  1462. P_P2P_CONNECTION_REQ_INFO_T prConnReqInfo = (P_P2P_CONNECTION_REQ_INFO_T) NULL;
  1463. do {
  1464. ASSERT_BREAK((prAdapter != NULL) && (prMsgHdr != NULL));
  1465. prP2pBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_P2P_INDEX]);
  1466. prP2pFsmInfo = prAdapter->rWifiVar.prP2pFsmInfo;
  1467. if (prP2pFsmInfo == NULL)
  1468. break;
  1469. prConnReqMsg = (P_MSG_P2P_CONNECTION_REQUEST_T) prMsgHdr;
  1470. prConnReqInfo = &(prP2pFsmInfo->rConnReqInfo);
  1471. prChnlReqInfo = &(prP2pFsmInfo->rChnlReqInfo);
  1472. DBGLOG(P2P, TRACE, "p2pFsmRunEventConnectionRequest\n");
  1473. if (prP2pBssInfo->eCurrentOPMode != OP_MODE_INFRASTRUCTURE)
  1474. break;
  1475. SET_NET_PWR_STATE_ACTIVE(prAdapter, NETWORK_TYPE_P2P_INDEX);
  1476. /* Make sure the state is in IDLE state. */
  1477. p2pFsmRunEventAbort(prAdapter, prP2pFsmInfo);
  1478. /* Update connection request information. */
  1479. prConnReqInfo->eConnRequest = P2P_CONNECTION_TYPE_GC;
  1480. COPY_MAC_ADDR(prConnReqInfo->aucBssid, prConnReqMsg->aucBssid);
  1481. kalMemCopy(&(prConnReqInfo->rSsidStruct), &(prConnReqMsg->rSsid), sizeof(P2P_SSID_STRUCT_T));
  1482. kalMemCopy(prConnReqInfo->aucIEBuf, prConnReqMsg->aucIEBuf, prConnReqMsg->u4IELen);
  1483. prConnReqInfo->u4BufLength = prConnReqMsg->u4IELen;
  1484. /* Find BSS Descriptor first. */
  1485. prP2pFsmInfo->prTargetBss = scanP2pSearchDesc(prAdapter, prConnReqInfo);
  1486. if (prP2pFsmInfo->prTargetBss == NULL) {
  1487. /* Update scan parameter... to scan target device. */
  1488. P_P2P_SCAN_REQ_INFO_T prScanReqInfo = &(prP2pFsmInfo->rScanReqInfo);
  1489. prScanReqInfo->ucNumChannelList = 1;
  1490. prScanReqInfo->eScanType = SCAN_TYPE_ACTIVE_SCAN;
  1491. prScanReqInfo->eChannelSet = SCAN_CHANNEL_SPECIFIED;
  1492. prScanReqInfo->arScanChannelList[0].ucChannelNum = prConnReqMsg->rChannelInfo.ucChannelNum;
  1493. prScanReqInfo->ucSsidNum = 1;
  1494. kalMemCopy(&(prScanReqInfo->arSsidStruct[0]), &(prConnReqMsg->rSsid),
  1495. sizeof(P2P_SSID_STRUCT_T));
  1496. prScanReqInfo->u4BufLength = 0; /* Prevent other P2P ID in IE. */
  1497. prScanReqInfo->fgIsAbort = TRUE;
  1498. p2pFsmStateTransition(prAdapter, prP2pFsmInfo, P2P_STATE_SCAN);
  1499. } else {
  1500. prChnlReqInfo->u8Cookie = 0;
  1501. prChnlReqInfo->ucReqChnlNum = prConnReqMsg->rChannelInfo.ucChannelNum;
  1502. prChnlReqInfo->eBand = prConnReqMsg->rChannelInfo.eBand;
  1503. prChnlReqInfo->eChnlSco = prConnReqMsg->eChnlSco;
  1504. prChnlReqInfo->u4MaxInterval = AIS_JOIN_CH_REQUEST_INTERVAL;
  1505. prChnlReqInfo->eChannelReqType = CHANNEL_REQ_TYPE_GC_JOIN_REQ;
  1506. p2pFsmStateTransition(prAdapter, prP2pFsmInfo, P2P_STATE_REQING_CHANNEL);
  1507. }
  1508. } while (FALSE);
  1509. if (prMsgHdr)
  1510. cnmMemFree(prAdapter, prMsgHdr);
  1511. } /* p2pFsmRunEventConnectionRequest */
  1512. /*----------------------------------------------------------------------------*/
  1513. /*!
  1514. * \brief This function is used to handle Connection Request from Supplicant.
  1515. *
  1516. * \param[in] prAdapter Pointer of ADAPTER_T
  1517. *
  1518. * \return none
  1519. */
  1520. /*----------------------------------------------------------------------------*/
  1521. VOID p2pFsmRunEventConnectionAbort(IN P_ADAPTER_T prAdapter, IN P_MSG_HDR_T prMsgHdr)
  1522. {
  1523. P_P2P_FSM_INFO_T prP2pFsmInfo = (P_P2P_FSM_INFO_T) NULL;
  1524. P_BSS_INFO_T prP2pBssInfo = (P_BSS_INFO_T) NULL;
  1525. P_MSG_P2P_CONNECTION_ABORT_T prDisconnMsg = (P_MSG_P2P_CONNECTION_ABORT_T) NULL;
  1526. /* P_STA_RECORD_T prTargetStaRec = (P_STA_RECORD_T)NULL; */
  1527. do {
  1528. ASSERT_BREAK((prAdapter != NULL) && (prMsgHdr != NULL));
  1529. DBGLOG(P2P, TRACE, "p2pFsmRunEventConnectionAbort: Connection Abort.\n");
  1530. prP2pFsmInfo = prAdapter->rWifiVar.prP2pFsmInfo;
  1531. if (prP2pFsmInfo == NULL)
  1532. break;
  1533. prP2pBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_P2P_INDEX]);
  1534. prDisconnMsg = (P_MSG_P2P_CONNECTION_ABORT_T) prMsgHdr;
  1535. switch (prP2pBssInfo->eCurrentOPMode) {
  1536. case OP_MODE_INFRASTRUCTURE:
  1537. {
  1538. UINT_8 aucBCBSSID[] = BC_BSSID;
  1539. if (!prP2pBssInfo->prStaRecOfAP) {
  1540. DBGLOG(P2P, TRACE, "GO's StaRec is NULL\n");
  1541. break;
  1542. }
  1543. if (UNEQUAL_MAC_ADDR(prP2pBssInfo->prStaRecOfAP->aucMacAddr, prDisconnMsg->aucTargetID)
  1544. && UNEQUAL_MAC_ADDR(prDisconnMsg->aucTargetID, aucBCBSSID)) {
  1545. DBGLOG(P2P, TRACE,
  1546. "Unequal MAC ADDR [" MACSTR ":" MACSTR "]\n",
  1547. MAC2STR(prP2pBssInfo->prStaRecOfAP->aucMacAddr),
  1548. MAC2STR(prDisconnMsg->aucTargetID));
  1549. break;
  1550. }
  1551. kalP2PGCIndicateConnectionStatus(prAdapter->prGlueInfo, NULL, NULL, 0, 0,
  1552. WLAN_STATUS_MEDIA_DISCONNECT_LOCALLY);
  1553. /* Stop rejoin timer if it is started. */
  1554. /* TODO: If it has. */
  1555. p2pFuncDisconnect(prAdapter, prP2pBssInfo->prStaRecOfAP,
  1556. prDisconnMsg->fgSendDeauth, prDisconnMsg->u2ReasonCode);
  1557. /* prTargetStaRec = prP2pBssInfo->prStaRecOfAP; */
  1558. /* Fix possible KE when RX Beacon & call nicPmIndicateBssConnected().
  1559. * hit prStaRecOfAP == NULL.
  1560. **/
  1561. p2pChangeMediaState(prAdapter, PARAM_MEDIA_STATE_DISCONNECTED);
  1562. prP2pBssInfo->prStaRecOfAP = NULL;
  1563. SET_NET_PWR_STATE_IDLE(prAdapter, NETWORK_TYPE_P2P_INDEX);
  1564. p2pFsmStateTransition(prAdapter, prP2pFsmInfo, P2P_STATE_IDLE);
  1565. }
  1566. break;
  1567. case OP_MODE_ACCESS_POINT:
  1568. {
  1569. P_LINK_T prStaRecOfClientList = &prP2pBssInfo->rStaRecOfClientList;
  1570. /* Search specific client device, and disconnect. */
  1571. /* 1. Send deauthentication frame. */
  1572. /* 2. Indication: Device disconnect. */
  1573. P_LINK_ENTRY_T prLinkEntry = (P_LINK_ENTRY_T) NULL;
  1574. P_STA_RECORD_T prCurrStaRec = (P_STA_RECORD_T) NULL;
  1575. DBGLOG(P2P, TRACE,
  1576. "Disconnecting with Target ID: " MACSTR "\n",
  1577. MAC2STR(prDisconnMsg->aucTargetID));
  1578. LINK_FOR_EACH(prLinkEntry, prStaRecOfClientList) {
  1579. prCurrStaRec = LINK_ENTRY(prLinkEntry, STA_RECORD_T, rLinkEntry);
  1580. ASSERT(prCurrStaRec);
  1581. if (EQUAL_MAC_ADDR(prCurrStaRec->aucMacAddr, prDisconnMsg->aucTargetID)) {
  1582. DBGLOG(P2P, TRACE,
  1583. "Disconnecting: " MACSTR "\n",
  1584. MAC2STR(prCurrStaRec->aucMacAddr));
  1585. /* Remove STA from client list. */
  1586. LINK_REMOVE_KNOWN_ENTRY(prStaRecOfClientList,
  1587. &prCurrStaRec->rLinkEntry);
  1588. /* Glue layer indication. */
  1589. /* kalP2PGOStationUpdate(prAdapter->prGlueInfo, prCurrStaRec, FALSE); */
  1590. /* Send deauth & do indication. */
  1591. p2pFuncDisconnect(prAdapter, prCurrStaRec,
  1592. prDisconnMsg->fgSendDeauth,
  1593. prDisconnMsg->u2ReasonCode);
  1594. /* prTargetStaRec = prCurrStaRec; */
  1595. break;
  1596. }
  1597. }
  1598. }
  1599. break;
  1600. case OP_MODE_P2P_DEVICE:
  1601. default:
  1602. ASSERT(FALSE);
  1603. break;
  1604. }
  1605. } while (FALSE);
  1606. /* 20120830 moved into p2pFuncDisconnect() */
  1607. /* if ((!prDisconnMsg->fgSendDeauth) && (prTargetStaRec)) { */
  1608. /* cnmStaRecFree(prAdapter, prTargetStaRec); */
  1609. /* } */
  1610. if (prMsgHdr)
  1611. cnmMemFree(prAdapter, prMsgHdr);
  1612. } /* p2pFsmRunEventConnectionAbort */
  1613. WLAN_STATUS
  1614. p2pFsmRunEventDeauthTxDone(IN P_ADAPTER_T prAdapter,
  1615. IN P_MSDU_INFO_T prMsduInfo, IN ENUM_TX_RESULT_CODE_T rTxDoneStatus)
  1616. {
  1617. P_STA_RECORD_T prStaRec = (P_STA_RECORD_T) NULL;
  1618. P_BSS_INFO_T prP2pBssInfo = (P_BSS_INFO_T) NULL;
  1619. ENUM_PARAM_MEDIA_STATE_T eOriMediaStatus;
  1620. do {
  1621. ASSERT_BREAK((prAdapter != NULL) && (prMsduInfo != NULL));
  1622. DBGLOG(P2P, TRACE, "Deauth TX Done\n");
  1623. prStaRec = cnmGetStaRecByIndex(prAdapter, prMsduInfo->ucStaRecIndex);
  1624. if (prStaRec == NULL) {
  1625. DBGLOG(P2P, TRACE, "Station Record NULL, Index:%d\n", prMsduInfo->ucStaRecIndex);
  1626. break;
  1627. }
  1628. prP2pBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_P2P_INDEX]);
  1629. eOriMediaStatus = prP2pBssInfo->eConnectionState;
  1630. /* Change station state. */
  1631. cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_1);
  1632. /* Reset Station Record Status. */
  1633. p2pFuncResetStaRecStatus(prAdapter, prStaRec);
  1634. /**/ cnmStaRecFree(prAdapter, prStaRec);
  1635. if ((prP2pBssInfo->eCurrentOPMode != OP_MODE_ACCESS_POINT) ||
  1636. (prP2pBssInfo->rStaRecOfClientList.u4NumElem == 0)) {
  1637. DBGLOG(P2P, TRACE, "No More Client, Media Status DISCONNECTED\n");
  1638. p2pChangeMediaState(prAdapter, PARAM_MEDIA_STATE_DISCONNECTED);
  1639. }
  1640. if (eOriMediaStatus != prP2pBssInfo->eConnectionState) {
  1641. /* Update Disconnected state to FW. */
  1642. nicUpdateBss(prAdapter, NETWORK_TYPE_P2P_INDEX);
  1643. }
  1644. } while (FALSE);
  1645. return WLAN_STATUS_SUCCESS;
  1646. } /* p2pFsmRunEventDeauthTxDone */
  1647. VOID p2pFsmRunEventMgmtFrameRegister(IN P_ADAPTER_T prAdapter, IN P_MSG_HDR_T prMsgHdr)
  1648. {
  1649. P_MSG_P2P_MGMT_FRAME_REGISTER_T prMgmtFrameRegister = (P_MSG_P2P_MGMT_FRAME_REGISTER_T) NULL;
  1650. P_P2P_FSM_INFO_T prP2pFsmInfo = (P_P2P_FSM_INFO_T) NULL;
  1651. do {
  1652. ASSERT_BREAK((prAdapter != NULL) && (prMsgHdr != NULL));
  1653. prP2pFsmInfo = prAdapter->rWifiVar.prP2pFsmInfo;
  1654. if (prP2pFsmInfo == NULL)
  1655. break;
  1656. prMgmtFrameRegister = (P_MSG_P2P_MGMT_FRAME_REGISTER_T) prMsgHdr;
  1657. p2pFuncMgmtFrameRegister(prAdapter,
  1658. prMgmtFrameRegister->u2FrameType,
  1659. prMgmtFrameRegister->fgIsRegister, &prP2pFsmInfo->u4P2pPacketFilter);
  1660. } while (FALSE);
  1661. if (prMsgHdr)
  1662. cnmMemFree(prAdapter, prMsgHdr);
  1663. } /* p2pFsmRunEventMgmtFrameRegister */
  1664. /*----------------------------------------------------------------------------*/
  1665. /*!
  1666. * \brief This function is call when RX deauthentication frame from the AIR.
  1667. * If we are under STA mode, we would go back to P2P Device.
  1668. * If we are under AP mode, we would stay in AP mode until disconnect event from HOST.
  1669. *
  1670. * \param[in] prAdapter Pointer of ADAPTER_T
  1671. *
  1672. * \return none
  1673. */
  1674. /*----------------------------------------------------------------------------*/
  1675. VOID p2pFsmRunEventRxDeauthentication(IN P_ADAPTER_T prAdapter, IN P_STA_RECORD_T prStaRec, IN P_SW_RFB_T prSwRfb)
  1676. {
  1677. P_BSS_INFO_T prP2pBssInfo = (P_BSS_INFO_T) NULL;
  1678. UINT_16 u2ReasonCode = 0;
  1679. do {
  1680. ASSERT_BREAK((prAdapter != NULL) && (prSwRfb != NULL));
  1681. if (prStaRec == NULL)
  1682. prStaRec = cnmGetStaRecByIndex(prAdapter, prSwRfb->ucStaRecIdx);
  1683. if (!prStaRec)
  1684. break;
  1685. prP2pBssInfo = &prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_P2P_INDEX];
  1686. if (prStaRec->ucStaState == STA_STATE_1)
  1687. break;
  1688. DBGLOG(P2P, TRACE, "RX Deauth\n");
  1689. switch (prP2pBssInfo->eCurrentOPMode) {
  1690. case OP_MODE_INFRASTRUCTURE:
  1691. if (authProcessRxDeauthFrame(prSwRfb,
  1692. prStaRec->aucMacAddr, &u2ReasonCode) == WLAN_STATUS_SUCCESS) {
  1693. P_WLAN_DEAUTH_FRAME_T prDeauthFrame = (P_WLAN_DEAUTH_FRAME_T) prSwRfb->pvHeader;
  1694. UINT_16 u2IELength = 0;
  1695. if (prP2pBssInfo->prStaRecOfAP != prStaRec)
  1696. break;
  1697. prStaRec->u2ReasonCode = u2ReasonCode;
  1698. u2IELength = prSwRfb->u2PacketLen - (WLAN_MAC_HEADER_LEN + REASON_CODE_FIELD_LEN);
  1699. ASSERT(prP2pBssInfo->prStaRecOfAP == prStaRec);
  1700. /* Indicate disconnect to Host. */
  1701. kalP2PGCIndicateConnectionStatus(prAdapter->prGlueInfo,
  1702. NULL,
  1703. prDeauthFrame->aucInfoElem, u2IELength, u2ReasonCode,
  1704. WLAN_STATUS_MEDIA_DISCONNECT);
  1705. prP2pBssInfo->prStaRecOfAP = NULL;
  1706. p2pFuncDisconnect(prAdapter, prStaRec, FALSE, u2ReasonCode);
  1707. }
  1708. break;
  1709. case OP_MODE_ACCESS_POINT:
  1710. /* Delete client from client list. */
  1711. if (authProcessRxDeauthFrame(prSwRfb,
  1712. prP2pBssInfo->aucBSSID, &u2ReasonCode) == WLAN_STATUS_SUCCESS) {
  1713. P_LINK_T prStaRecOfClientList = (P_LINK_T) NULL;
  1714. P_LINK_ENTRY_T prLinkEntry = (P_LINK_ENTRY_T) NULL;
  1715. P_STA_RECORD_T prCurrStaRec = (P_STA_RECORD_T) NULL;
  1716. prStaRecOfClientList = &prP2pBssInfo->rStaRecOfClientList;
  1717. LINK_FOR_EACH(prLinkEntry, prStaRecOfClientList) {
  1718. prCurrStaRec = LINK_ENTRY(prLinkEntry, STA_RECORD_T, rLinkEntry);
  1719. ASSERT(prCurrStaRec);
  1720. if (EQUAL_MAC_ADDR(prCurrStaRec->aucMacAddr, prStaRec->aucMacAddr)) {
  1721. /* Remove STA from client list. */
  1722. LINK_REMOVE_KNOWN_ENTRY(prStaRecOfClientList,
  1723. &prCurrStaRec->rLinkEntry);
  1724. /* Indicate to Host. */
  1725. /* kalP2PGOStationUpdate(prAdapter->prGlueInfo, prStaRec, FALSE); */
  1726. /* Indicate disconnect to Host. */
  1727. p2pFuncDisconnect(prAdapter, prStaRec, FALSE, u2ReasonCode);
  1728. break;
  1729. }
  1730. }
  1731. }
  1732. break;
  1733. case OP_MODE_P2P_DEVICE:
  1734. default:
  1735. /* Findout why someone sent deauthentication frame to us. */
  1736. ASSERT(FALSE);
  1737. break;
  1738. }
  1739. DBGLOG(P2P, TRACE, "Deauth Reason:%d\n", u2ReasonCode);
  1740. } while (FALSE);
  1741. } /* p2pFsmRunEventRxDeauthentication */
  1742. /*----------------------------------------------------------------------------*/
  1743. /*!
  1744. * \brief This function is call when RX deauthentication frame from the AIR.
  1745. * If we are under STA mode, we would go back to P2P Device.
  1746. * If we are under AP mode, we would stay in AP mode until disconnect event from HOST.
  1747. *
  1748. * \param[in] prAdapter Pointer of ADAPTER_T
  1749. *
  1750. * \return none
  1751. */
  1752. /*----------------------------------------------------------------------------*/
  1753. VOID p2pFsmRunEventRxDisassociation(IN P_ADAPTER_T prAdapter, IN P_STA_RECORD_T prStaRec, IN P_SW_RFB_T prSwRfb)
  1754. {
  1755. P_BSS_INFO_T prP2pBssInfo = (P_BSS_INFO_T) NULL;
  1756. UINT_16 u2ReasonCode = 0;
  1757. do {
  1758. ASSERT_BREAK((prAdapter != NULL) && (prSwRfb != NULL));
  1759. if (prStaRec == NULL)
  1760. prStaRec = cnmGetStaRecByIndex(prAdapter, prSwRfb->ucStaRecIdx);
  1761. prP2pBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_P2P_INDEX]);
  1762. if (prStaRec->ucStaState == STA_STATE_1)
  1763. break;
  1764. DBGLOG(P2P, TRACE, "RX Disassoc\n");
  1765. switch (prP2pBssInfo->eCurrentOPMode) {
  1766. case OP_MODE_INFRASTRUCTURE:
  1767. if (assocProcessRxDisassocFrame(prAdapter,
  1768. prSwRfb,
  1769. prStaRec->aucMacAddr,
  1770. &prStaRec->u2ReasonCode) == WLAN_STATUS_SUCCESS) {
  1771. P_WLAN_DISASSOC_FRAME_T prDisassocFrame = (P_WLAN_DISASSOC_FRAME_T) prSwRfb->pvHeader;
  1772. UINT_16 u2IELength = 0;
  1773. ASSERT(prP2pBssInfo->prStaRecOfAP == prStaRec);
  1774. if (prP2pBssInfo->prStaRecOfAP != prStaRec)
  1775. break;
  1776. u2IELength = prSwRfb->u2PacketLen - (WLAN_MAC_HEADER_LEN + REASON_CODE_FIELD_LEN);
  1777. /* Indicate disconnect to Host. */
  1778. kalP2PGCIndicateConnectionStatus(prAdapter->prGlueInfo,
  1779. NULL,
  1780. prDisassocFrame->aucInfoElem,
  1781. u2IELength, prStaRec->u2ReasonCode,
  1782. WLAN_STATUS_MEDIA_DISCONNECT);
  1783. prP2pBssInfo->prStaRecOfAP = NULL;
  1784. p2pFuncDisconnect(prAdapter, prStaRec, FALSE, prStaRec->u2ReasonCode);
  1785. }
  1786. break;
  1787. case OP_MODE_ACCESS_POINT:
  1788. /* Delete client from client list. */
  1789. if (assocProcessRxDisassocFrame(prAdapter,
  1790. prSwRfb,
  1791. prP2pBssInfo->aucBSSID, &u2ReasonCode) == WLAN_STATUS_SUCCESS) {
  1792. P_LINK_T prStaRecOfClientList = (P_LINK_T) NULL;
  1793. P_LINK_ENTRY_T prLinkEntry = (P_LINK_ENTRY_T) NULL;
  1794. P_STA_RECORD_T prCurrStaRec = (P_STA_RECORD_T) NULL;
  1795. prStaRecOfClientList = &prP2pBssInfo->rStaRecOfClientList;
  1796. LINK_FOR_EACH(prLinkEntry, prStaRecOfClientList) {
  1797. prCurrStaRec = LINK_ENTRY(prLinkEntry, STA_RECORD_T, rLinkEntry);
  1798. ASSERT(prCurrStaRec);
  1799. if (EQUAL_MAC_ADDR(prCurrStaRec->aucMacAddr, prStaRec->aucMacAddr)) {
  1800. /* Remove STA from client list. */
  1801. LINK_REMOVE_KNOWN_ENTRY(prStaRecOfClientList,
  1802. &prCurrStaRec->rLinkEntry);
  1803. /* Indicate to Host. */
  1804. /* kalP2PGOStationUpdate(prAdapter->prGlueInfo, prStaRec, FALSE); */
  1805. /* Indicate disconnect to Host. */
  1806. p2pFuncDisconnect(prAdapter, prStaRec, FALSE, u2ReasonCode);
  1807. break;
  1808. }
  1809. }
  1810. }
  1811. break;
  1812. case OP_MODE_P2P_DEVICE:
  1813. default:
  1814. ASSERT(FALSE);
  1815. break;
  1816. }
  1817. } while (FALSE);
  1818. } /* p2pFsmRunEventRxDisassociation */
  1819. /*----------------------------------------------------------------------------*/
  1820. /*!
  1821. * \brief This function is called when a probe request frame is received.
  1822. *
  1823. * \param[in] prAdapter Pointer of ADAPTER_T
  1824. *
  1825. * \return boolean value if probe response frame is accepted & need cancel scan request.
  1826. */
  1827. /*----------------------------------------------------------------------------*/
  1828. VOID p2pFsmRunEventRxProbeResponseFrame(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb, IN P_BSS_DESC_T prBssDesc)
  1829. {
  1830. P_P2P_FSM_INFO_T prP2pFsmInfo = (P_P2P_FSM_INFO_T) NULL;
  1831. P_P2P_CONNECTION_SETTINGS_T prP2pConnSettings = (P_P2P_CONNECTION_SETTINGS_T) NULL;
  1832. P_WLAN_MAC_MGMT_HEADER_T prMgtHdr = (P_WLAN_MAC_MGMT_HEADER_T) NULL;
  1833. P_BSS_INFO_T prP2pBssInfo = (P_BSS_INFO_T) NULL;
  1834. do {
  1835. ASSERT_BREAK((prAdapter != NULL) && (prSwRfb != NULL) && (prBssDesc != NULL));
  1836. prP2pFsmInfo = prAdapter->rWifiVar.prP2pFsmInfo;
  1837. prP2pConnSettings = prAdapter->rWifiVar.prP2PConnSettings;
  1838. prP2pBssInfo = &prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_P2P_INDEX];
  1839. /* There is a connection request. */
  1840. prMgtHdr = (P_WLAN_MAC_MGMT_HEADER_T) prSwRfb->pvHeader;
  1841. } while (FALSE);
  1842. } /* p2pFsmRunEventRxProbeResponseFrame */
  1843. /*----------------------------------------------------------------------------*/
  1844. /*!
  1845. * @brief This function is used to generate P2P IE for Beacon frame.
  1846. *
  1847. * @param[in] prMsduInfo Pointer to the composed MSDU_INFO_T.
  1848. *
  1849. * @return none
  1850. */
  1851. /*----------------------------------------------------------------------------*/
  1852. VOID p2pGenerateP2P_IEForAssocReq(IN P_ADAPTER_T prAdapter, IN P_MSDU_INFO_T prMsduInfo)
  1853. {
  1854. P_P2P_FSM_INFO_T prP2pFsmInfo = (P_P2P_FSM_INFO_T) NULL;
  1855. P_STA_RECORD_T prStaRec = (P_STA_RECORD_T) NULL;
  1856. do {
  1857. ASSERT_BREAK((prAdapter != NULL) && (prMsduInfo != NULL));
  1858. prP2pFsmInfo = prAdapter->rWifiVar.prP2pFsmInfo;
  1859. prStaRec = cnmGetStaRecByIndex(prAdapter, prMsduInfo->ucStaRecIndex);
  1860. if (IS_STA_IN_P2P(prStaRec)) {
  1861. /* Do nothing */
  1862. /* TODO: */
  1863. }
  1864. } while (FALSE);
  1865. } /* end of p2pGenerateP2P_IEForAssocReq() */
  1866. /*----------------------------------------------------------------------------*/
  1867. /*!
  1868. * @brief This function is used to generate P2P IE for Probe Request frame.
  1869. *
  1870. * @param[in] prMsduInfo Pointer to the composed MSDU_INFO_T.
  1871. *
  1872. * @return none
  1873. */
  1874. /*----------------------------------------------------------------------------*/
  1875. VOID
  1876. p2pGenerateP2P_IEForProbeReq(IN P_ADAPTER_T prAdapter, IN PUINT_16 pu2Offset, IN PUINT_8 pucBuf, IN UINT_16 u2BufSize)
  1877. {
  1878. ASSERT(prAdapter);
  1879. ASSERT(pucBuf);
  1880. /* TODO: */
  1881. } /* end of p2pGenerateP2P_IEForProbReq() */
  1882. /*----------------------------------------------------------------------------*/
  1883. /*!
  1884. * @brief This function is used to calculate P2P IE length for Beacon frame.
  1885. *
  1886. * @param[in] eNetTypeIndex Specify which network
  1887. * @param[in] prStaRec Pointer to the STA_RECORD_T
  1888. *
  1889. * @return The length of P2P IE added
  1890. */
  1891. /*----------------------------------------------------------------------------*/
  1892. UINT_32
  1893. p2pCalculateP2P_IELenForProbeReq(IN P_ADAPTER_T prAdapter,
  1894. IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex, IN P_STA_RECORD_T prStaRec)
  1895. {
  1896. if (eNetTypeIndex != NETWORK_TYPE_P2P_INDEX)
  1897. return 0;
  1898. /* TODO: */
  1899. return 0;
  1900. } /* end of p2pCalculateP2P_IELenForProbeReq() */
  1901. /*----------------------------------------------------------------------------*/
  1902. /*!
  1903. * \brief
  1904. *
  1905. * \param[in]
  1906. *
  1907. * \return none
  1908. */
  1909. /*----------------------------------------------------------------------------*/
  1910. WLAN_STATUS p2pRxPublicActionFrame(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb)
  1911. {
  1912. WLAN_STATUS rWlanStatus = WLAN_STATUS_SUCCESS;
  1913. P_P2P_PUBLIC_ACTION_FRAME_T prPublicActionFrame = (P_P2P_PUBLIC_ACTION_FRAME_T) NULL;
  1914. P_P2P_FSM_INFO_T prP2pFsmInfo = (P_P2P_FSM_INFO_T) NULL;
  1915. ASSERT(prSwRfb);
  1916. ASSERT(prAdapter);
  1917. prPublicActionFrame = (P_P2P_PUBLIC_ACTION_FRAME_T) prSwRfb->pvHeader;
  1918. prP2pFsmInfo = prAdapter->rWifiVar.prP2pFsmInfo;
  1919. DBGLOG(P2P, TRACE, "RX Public Action Frame Token:%d.\n", prPublicActionFrame->ucDialogToken);
  1920. if (prPublicActionFrame->ucCategory != CATEGORY_PUBLIC_ACTION)
  1921. return rWlanStatus;
  1922. switch (prPublicActionFrame->ucAction) {
  1923. case ACTION_PUBLIC_WIFI_DIRECT:
  1924. break;
  1925. case ACTION_GAS_INITIAL_REQUEST:
  1926. case ACTION_GAS_INITIAL_RESPONSE:
  1927. case ACTION_GAS_COMEBACK_REQUEST:
  1928. case ACTION_GAS_COMEBACK_RESPONSE:
  1929. break;
  1930. default:
  1931. break;
  1932. }
  1933. return rWlanStatus;
  1934. } /* p2pRxPublicActionFrame */
  1935. WLAN_STATUS p2pRxActionFrame(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb)
  1936. {
  1937. WLAN_STATUS rWlanStatus = WLAN_STATUS_SUCCESS;
  1938. P_P2P_ACTION_FRAME_T prP2pActionFrame = (P_P2P_ACTION_FRAME_T) NULL;
  1939. UINT_8 aucOui[3] = VENDOR_OUI_WFA_SPECIFIC;
  1940. do {
  1941. ASSERT_BREAK((prAdapter != NULL) && (prSwRfb != NULL));
  1942. prP2pActionFrame = (P_P2P_ACTION_FRAME_T) prSwRfb->pvHeader;
  1943. if (prP2pActionFrame->ucCategory != CATEGORY_VENDOR_SPECIFIC_ACTION) {
  1944. DBGLOG(P2P, TRACE, "RX Action Frame but not vendor specific.\n");
  1945. break;
  1946. }
  1947. if ((prP2pActionFrame->ucOuiType != VENDOR_OUI_TYPE_P2P) ||
  1948. (prP2pActionFrame->aucOui[0] != aucOui[0]) ||
  1949. (prP2pActionFrame->aucOui[1] != aucOui[1]) || (prP2pActionFrame->aucOui[2] != aucOui[2])) {
  1950. DBGLOG(P2P, TRACE, "RX Vendor Specific Action Frame but not P2P Type or not WFA OUI.\n");
  1951. break;
  1952. }
  1953. } while (FALSE);
  1954. return rWlanStatus;
  1955. } /* p2pRxActionFrame */
  1956. #endif /* CFG_ENABLE_WIFI_DIRECT */