hci.h 69 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975
  1. /*
  2. BlueZ - Bluetooth protocol stack for Linux
  3. Copyright (C) 2000-2001 Qualcomm Incorporated
  4. Copyright 2023-2024 NXP
  5. Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com>
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License version 2 as
  8. published by the Free Software Foundation;
  9. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  10. OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  11. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
  12. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
  13. CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
  14. WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  15. ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  16. OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  17. ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
  18. COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
  19. SOFTWARE IS DISCLAIMED.
  20. */
  21. #ifndef __HCI_H
  22. #define __HCI_H
  23. #define HCI_MAX_ACL_SIZE 1024
  24. #define HCI_MAX_SCO_SIZE 255
  25. #define HCI_MAX_ISO_SIZE 251
  26. #define HCI_MAX_ISO_BIS 31
  27. #define HCI_MAX_EVENT_SIZE 260
  28. #define HCI_MAX_FRAME_SIZE (HCI_MAX_ACL_SIZE + 4)
  29. #define HCI_LINK_KEY_SIZE 16
  30. #define HCI_MAX_CPB_DATA_SIZE 252
  31. /* HCI dev events */
  32. #define HCI_DEV_REG 1
  33. #define HCI_DEV_UNREG 2
  34. #define HCI_DEV_UP 3
  35. #define HCI_DEV_DOWN 4
  36. #define HCI_DEV_SUSPEND 5
  37. #define HCI_DEV_RESUME 6
  38. #define HCI_DEV_OPEN 7
  39. #define HCI_DEV_CLOSE 8
  40. #define HCI_DEV_SETUP 9
  41. /* HCI notify events */
  42. #define HCI_NOTIFY_CONN_ADD 1
  43. #define HCI_NOTIFY_CONN_DEL 2
  44. #define HCI_NOTIFY_VOICE_SETTING 3
  45. #define HCI_NOTIFY_ENABLE_SCO_CVSD 4
  46. #define HCI_NOTIFY_ENABLE_SCO_TRANSP 5
  47. #define HCI_NOTIFY_DISABLE_SCO 6
  48. /* HCI bus types */
  49. #define HCI_VIRTUAL 0
  50. #define HCI_USB 1
  51. #define HCI_PCCARD 2
  52. #define HCI_UART 3
  53. #define HCI_RS232 4
  54. #define HCI_PCI 5
  55. #define HCI_SDIO 6
  56. #define HCI_SPI 7
  57. #define HCI_I2C 8
  58. #define HCI_SMD 9
  59. #define HCI_VIRTIO 10
  60. /* HCI device quirks */
  61. enum {
  62. /* When this quirk is set, the HCI Reset command is send when
  63. * closing the transport instead of when opening it.
  64. *
  65. * This quirk must be set before hci_register_dev is called.
  66. */
  67. HCI_QUIRK_RESET_ON_CLOSE,
  68. /* When this quirk is set, the device is turned into a raw-only
  69. * device and it will stay in unconfigured state.
  70. *
  71. * This quirk must be set before hci_register_dev is called.
  72. */
  73. HCI_QUIRK_RAW_DEVICE,
  74. /* When this quirk is set, the buffer sizes reported by
  75. * HCI Read Buffer Size command are corrected if invalid.
  76. *
  77. * This quirk must be set before hci_register_dev is called.
  78. */
  79. HCI_QUIRK_FIXUP_BUFFER_SIZE,
  80. /* When this quirk is set, then a controller that does not
  81. * indicate support for Inquiry Result with RSSI is assumed to
  82. * support it anyway. Some early Bluetooth 1.2 controllers had
  83. * wrongly configured local features that will require forcing
  84. * them to enable this mode. Getting RSSI information with the
  85. * inquiry responses is preferred since it allows for a better
  86. * user experience.
  87. *
  88. * This quirk must be set before hci_register_dev is called.
  89. */
  90. HCI_QUIRK_FIXUP_INQUIRY_MODE,
  91. /* When this quirk is set, then the HCI Read Local Supported
  92. * Commands command is not supported. In general Bluetooth 1.2
  93. * and later controllers should support this command. However
  94. * some controllers indicate Bluetooth 1.2 support, but do
  95. * not support this command.
  96. *
  97. * This quirk must be set before hci_register_dev is called.
  98. */
  99. HCI_QUIRK_BROKEN_LOCAL_COMMANDS,
  100. /* When this quirk is set, then no stored link key handling
  101. * is performed. This is mainly due to the fact that the
  102. * HCI Delete Stored Link Key command is advertised, but
  103. * not supported.
  104. *
  105. * This quirk must be set before hci_register_dev is called.
  106. */
  107. HCI_QUIRK_BROKEN_STORED_LINK_KEY,
  108. /* When this quirk is set, an external configuration step
  109. * is required and will be indicated with the controller
  110. * configuration.
  111. *
  112. * This quirk can be set before hci_register_dev is called or
  113. * during the hdev->setup vendor callback.
  114. */
  115. HCI_QUIRK_EXTERNAL_CONFIG,
  116. /* When this quirk is set, the public Bluetooth address
  117. * initially reported by HCI Read BD Address command
  118. * is considered invalid. Controller configuration is
  119. * required before this device can be used.
  120. *
  121. * This quirk can be set before hci_register_dev is called or
  122. * during the hdev->setup vendor callback.
  123. */
  124. HCI_QUIRK_INVALID_BDADDR,
  125. /* When this quirk is set, the public Bluetooth address
  126. * initially reported by HCI Read BD Address command
  127. * is considered invalid. The public BD Address can be
  128. * specified in the fwnode property 'local-bd-address'.
  129. * If this property does not exist or is invalid controller
  130. * configuration is required before this device can be used.
  131. *
  132. * This quirk can be set before hci_register_dev is called or
  133. * during the hdev->setup vendor callback.
  134. */
  135. HCI_QUIRK_USE_BDADDR_PROPERTY,
  136. /* When this quirk is set, the Bluetooth Device Address provided by
  137. * the 'local-bd-address' fwnode property is incorrectly specified in
  138. * big-endian order.
  139. *
  140. * This quirk can be set before hci_register_dev is called or
  141. * during the hdev->setup vendor callback.
  142. */
  143. HCI_QUIRK_BDADDR_PROPERTY_BROKEN,
  144. /* When this quirk is set, the duplicate filtering during
  145. * scanning is based on Bluetooth devices addresses. To allow
  146. * RSSI based updates, restart scanning if needed.
  147. *
  148. * This quirk can be set before hci_register_dev is called or
  149. * during the hdev->setup vendor callback.
  150. */
  151. HCI_QUIRK_STRICT_DUPLICATE_FILTER,
  152. /* When this quirk is set, LE scan and BR/EDR inquiry is done
  153. * simultaneously, otherwise it's interleaved.
  154. *
  155. * This quirk can be set before hci_register_dev is called or
  156. * during the hdev->setup vendor callback.
  157. */
  158. HCI_QUIRK_SIMULTANEOUS_DISCOVERY,
  159. /* When this quirk is set, the enabling of diagnostic mode is
  160. * not persistent over HCI Reset. Every time the controller
  161. * is brought up it needs to be reprogrammed.
  162. *
  163. * This quirk can be set before hci_register_dev is called or
  164. * during the hdev->setup vendor callback.
  165. */
  166. HCI_QUIRK_NON_PERSISTENT_DIAG,
  167. /* When this quirk is set, setup() would be run after every
  168. * open() and not just after the first open().
  169. *
  170. * This quirk can be set before hci_register_dev is called or
  171. * during the hdev->setup vendor callback.
  172. *
  173. */
  174. HCI_QUIRK_NON_PERSISTENT_SETUP,
  175. /* When this quirk is set, wide band speech is supported by
  176. * the driver since no reliable mechanism exist to report
  177. * this from the hardware, a driver flag is use to convey
  178. * this support
  179. *
  180. * This quirk must be set before hci_register_dev is called.
  181. */
  182. HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED,
  183. /* When this quirk is set, the LE states reported through the
  184. * HCI_LE_READ_SUPPORTED_STATES are invalid/broken.
  185. *
  186. * This mechanism is necessary as many controllers have been seen has
  187. * having trouble initiating a connectable advertisement despite the
  188. * state combination being reported as supported.
  189. *
  190. * This quirk can be set before hci_register_dev is called or
  191. * during the hdev->setup vendor callback.
  192. */
  193. HCI_QUIRK_BROKEN_LE_STATES,
  194. /* When this quirk is set, then erroneous data reporting
  195. * is ignored. This is mainly due to the fact that the HCI
  196. * Read Default Erroneous Data Reporting command is advertised,
  197. * but not supported; these controllers often reply with unknown
  198. * command and tend to lock up randomly. Needing a hard reset.
  199. *
  200. * This quirk can be set before hci_register_dev is called or
  201. * during the hdev->setup vendor callback.
  202. */
  203. HCI_QUIRK_BROKEN_ERR_DATA_REPORTING,
  204. /*
  205. * When this quirk is set, then the hci_suspend_notifier is not
  206. * registered. This is intended for devices which drop completely
  207. * from the bus on system-suspend and which will show up as a new
  208. * HCI after resume.
  209. */
  210. HCI_QUIRK_NO_SUSPEND_NOTIFIER,
  211. /*
  212. * When this quirk is set, LE tx power is not queried on startup
  213. * and the min/max tx power values default to HCI_TX_POWER_INVALID.
  214. *
  215. * This quirk can be set before hci_register_dev is called or
  216. * during the hdev->setup vendor callback.
  217. */
  218. HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER,
  219. /* When this quirk is set, HCI_OP_SET_EVENT_FLT requests with
  220. * HCI_FLT_CLEAR_ALL are ignored and event filtering is
  221. * completely avoided. A subset of the CSR controller
  222. * clones struggle with this and instantly lock up.
  223. *
  224. * Note that devices using this must (separately) disable
  225. * runtime suspend, because event filtering takes place there.
  226. */
  227. HCI_QUIRK_BROKEN_FILTER_CLEAR_ALL,
  228. /*
  229. * When this quirk is set, disables the use of
  230. * HCI_OP_ENHANCED_SETUP_SYNC_CONN command to setup SCO connections.
  231. *
  232. * This quirk can be set before hci_register_dev is called or
  233. * during the hdev->setup vendor callback.
  234. */
  235. HCI_QUIRK_BROKEN_ENHANCED_SETUP_SYNC_CONN,
  236. /*
  237. * When this quirk is set, the HCI_OP_LE_SET_EXT_SCAN_ENABLE command is
  238. * disabled. This is required for some Broadcom controllers which
  239. * erroneously claim to support extended scanning.
  240. *
  241. * This quirk can be set before hci_register_dev is called or
  242. * during the hdev->setup vendor callback.
  243. */
  244. HCI_QUIRK_BROKEN_EXT_SCAN,
  245. /*
  246. * When this quirk is set, the HCI_OP_GET_MWS_TRANSPORT_CONFIG command is
  247. * disabled. This is required for some Broadcom controllers which
  248. * erroneously claim to support MWS Transport Layer Configuration.
  249. *
  250. * This quirk can be set before hci_register_dev is called or
  251. * during the hdev->setup vendor callback.
  252. */
  253. HCI_QUIRK_BROKEN_MWS_TRANSPORT_CONFIG,
  254. /* When this quirk is set, max_page for local extended features
  255. * is set to 1, even if controller reports higher number. Some
  256. * controllers (e.g. RTL8723CS) report more pages, but they
  257. * don't actually support features declared there.
  258. */
  259. HCI_QUIRK_BROKEN_LOCAL_EXT_FEATURES_PAGE_2,
  260. /*
  261. * When this quirk is set, the HCI_OP_LE_SET_RPA_TIMEOUT command is
  262. * skipped during initialization. This is required for the Actions
  263. * Semiconductor ATS2851 based controllers, which erroneously claims
  264. * to support it.
  265. */
  266. HCI_QUIRK_BROKEN_SET_RPA_TIMEOUT,
  267. /*
  268. * When this quirk is set, the HCI_OP_LE_EXT_CREATE_CONN command is
  269. * disabled. This is required for the Actions Semiconductor ATS2851
  270. * based controllers, which erroneously claims to support it.
  271. */
  272. HCI_QUIRK_BROKEN_EXT_CREATE_CONN,
  273. /*
  274. * When this quirk is set, the command WRITE_AUTH_PAYLOAD_TIMEOUT is
  275. * skipped. This is required for the Actions Semiconductor ATS2851
  276. * based controllers, due to a race condition in pairing process.
  277. */
  278. HCI_QUIRK_BROKEN_WRITE_AUTH_PAYLOAD_TIMEOUT,
  279. /* When this quirk is set, MSFT extension monitor tracking by
  280. * address filter is supported. Since tracking quantity of each
  281. * pattern is limited, this feature supports tracking multiple
  282. * devices concurrently if controller supports multiple
  283. * address filters.
  284. *
  285. * This quirk must be set before hci_register_dev is called.
  286. */
  287. HCI_QUIRK_USE_MSFT_EXT_ADDRESS_FILTER,
  288. /*
  289. * When this quirk is set, LE Coded PHY shall not be used. This is
  290. * required for some Intel controllers which erroneously claim to
  291. * support it but it causes problems with extended scanning.
  292. *
  293. * This quirk can be set before hci_register_dev is called or
  294. * during the hdev->setup vendor callback.
  295. */
  296. HCI_QUIRK_BROKEN_LE_CODED,
  297. /*
  298. * When this quirk is set, the HCI_OP_READ_ENC_KEY_SIZE command is
  299. * skipped during an HCI_EV_ENCRYPT_CHANGE event. This is required
  300. * for Actions Semiconductor ATS2851 based controllers, which erroneously
  301. * claim to support it.
  302. */
  303. HCI_QUIRK_BROKEN_READ_ENC_KEY_SIZE,
  304. /*
  305. * When this quirk is set, the reserved bits of Primary/Secondary_PHY
  306. * inside the LE Extended Advertising Report events are discarded.
  307. * This is required for some Apple/Broadcom controllers which
  308. * abuse these reserved bits for unrelated flags.
  309. *
  310. * This quirk can be set before hci_register_dev is called or
  311. * during the hdev->setup vendor callback.
  312. */
  313. HCI_QUIRK_FIXUP_LE_EXT_ADV_REPORT_PHY,
  314. /* When this quirk is set, the HCI_OP_READ_VOICE_SETTING command is
  315. * skipped. This is required for a subset of the CSR controller clones
  316. * which erroneously claim to support it.
  317. *
  318. * This quirk must be set before hci_register_dev is called.
  319. */
  320. HCI_QUIRK_BROKEN_READ_VOICE_SETTING,
  321. /* When this quirk is set, the HCI_OP_READ_PAGE_SCAN_TYPE command is
  322. * skipped. This is required for a subset of the CSR controller clones
  323. * which erroneously claim to support it.
  324. *
  325. * This quirk must be set before hci_register_dev is called.
  326. */
  327. HCI_QUIRK_BROKEN_READ_PAGE_SCAN_TYPE,
  328. };
  329. /* HCI device flags */
  330. enum {
  331. HCI_UP,
  332. HCI_INIT,
  333. HCI_RUNNING,
  334. HCI_PSCAN,
  335. HCI_ISCAN,
  336. HCI_AUTH,
  337. HCI_ENCRYPT,
  338. HCI_INQUIRY,
  339. HCI_RAW,
  340. HCI_RESET,
  341. };
  342. /* HCI socket flags */
  343. enum {
  344. HCI_SOCK_TRUSTED,
  345. HCI_MGMT_INDEX_EVENTS,
  346. HCI_MGMT_UNCONF_INDEX_EVENTS,
  347. HCI_MGMT_EXT_INDEX_EVENTS,
  348. HCI_MGMT_EXT_INFO_EVENTS,
  349. HCI_MGMT_OPTION_EVENTS,
  350. HCI_MGMT_SETTING_EVENTS,
  351. HCI_MGMT_DEV_CLASS_EVENTS,
  352. HCI_MGMT_LOCAL_NAME_EVENTS,
  353. HCI_MGMT_OOB_DATA_EVENTS,
  354. HCI_MGMT_EXP_FEATURE_EVENTS,
  355. };
  356. /*
  357. * BR/EDR and/or LE controller flags: the flags defined here should represent
  358. * states from the controller.
  359. */
  360. enum {
  361. HCI_SETUP,
  362. HCI_CONFIG,
  363. HCI_DEBUGFS_CREATED,
  364. HCI_POWERING_DOWN,
  365. HCI_AUTO_OFF,
  366. HCI_RFKILLED,
  367. HCI_MGMT,
  368. HCI_BONDABLE,
  369. HCI_SERVICE_CACHE,
  370. HCI_KEEP_DEBUG_KEYS,
  371. HCI_USE_DEBUG_KEYS,
  372. HCI_UNREGISTER,
  373. HCI_UNCONFIGURED,
  374. HCI_USER_CHANNEL,
  375. HCI_EXT_CONFIGURED,
  376. HCI_LE_ADV,
  377. HCI_LE_PER_ADV,
  378. HCI_LE_SCAN,
  379. HCI_SSP_ENABLED,
  380. HCI_SC_ENABLED,
  381. HCI_SC_ONLY,
  382. HCI_PRIVACY,
  383. HCI_LIMITED_PRIVACY,
  384. HCI_RPA_EXPIRED,
  385. HCI_RPA_RESOLVING,
  386. HCI_LE_ENABLED,
  387. HCI_ADVERTISING,
  388. HCI_ADVERTISING_CONNECTABLE,
  389. HCI_CONNECTABLE,
  390. HCI_DISCOVERABLE,
  391. HCI_LIMITED_DISCOVERABLE,
  392. HCI_LINK_SECURITY,
  393. HCI_PERIODIC_INQ,
  394. HCI_FAST_CONNECTABLE,
  395. HCI_BREDR_ENABLED,
  396. HCI_LE_SCAN_INTERRUPTED,
  397. HCI_WIDEBAND_SPEECH_ENABLED,
  398. HCI_EVENT_FILTER_CONFIGURED,
  399. HCI_PA_SYNC,
  400. HCI_DUT_MODE,
  401. HCI_VENDOR_DIAG,
  402. HCI_FORCE_BREDR_SMP,
  403. HCI_FORCE_STATIC_ADDR,
  404. HCI_LL_RPA_RESOLUTION,
  405. HCI_ENABLE_LL_PRIVACY,
  406. HCI_CMD_PENDING,
  407. HCI_FORCE_NO_MITM,
  408. HCI_QUALITY_REPORT,
  409. HCI_OFFLOAD_CODECS_ENABLED,
  410. HCI_LE_SIMULTANEOUS_ROLES,
  411. HCI_CMD_DRAIN_WORKQUEUE,
  412. HCI_MESH_EXPERIMENTAL,
  413. HCI_MESH,
  414. HCI_MESH_SENDING,
  415. __HCI_NUM_FLAGS,
  416. };
  417. /* HCI timeouts */
  418. #define HCI_DISCONN_TIMEOUT msecs_to_jiffies(2000) /* 2 seconds */
  419. #define HCI_PAIRING_TIMEOUT msecs_to_jiffies(60000) /* 60 seconds */
  420. #define HCI_INIT_TIMEOUT msecs_to_jiffies(10000) /* 10 seconds */
  421. #define HCI_CMD_TIMEOUT msecs_to_jiffies(2000) /* 2 seconds */
  422. #define HCI_NCMD_TIMEOUT msecs_to_jiffies(4000) /* 4 seconds */
  423. #define HCI_ACL_TX_TIMEOUT msecs_to_jiffies(45000) /* 45 seconds */
  424. #define HCI_AUTO_OFF_TIMEOUT msecs_to_jiffies(2000) /* 2 seconds */
  425. #define HCI_ACL_CONN_TIMEOUT msecs_to_jiffies(20000) /* 20 seconds */
  426. #define HCI_LE_CONN_TIMEOUT msecs_to_jiffies(20000) /* 20 seconds */
  427. /* HCI data types */
  428. #define HCI_COMMAND_PKT 0x01
  429. #define HCI_ACLDATA_PKT 0x02
  430. #define HCI_SCODATA_PKT 0x03
  431. #define HCI_EVENT_PKT 0x04
  432. #define HCI_ISODATA_PKT 0x05
  433. #define HCI_DIAG_PKT 0xf0
  434. #define HCI_VENDOR_PKT 0xff
  435. /* HCI packet types */
  436. #define HCI_DM1 0x0008
  437. #define HCI_DM3 0x0400
  438. #define HCI_DM5 0x4000
  439. #define HCI_DH1 0x0010
  440. #define HCI_DH3 0x0800
  441. #define HCI_DH5 0x8000
  442. /* HCI packet types inverted masks */
  443. #define HCI_2DH1 0x0002
  444. #define HCI_3DH1 0x0004
  445. #define HCI_2DH3 0x0100
  446. #define HCI_3DH3 0x0200
  447. #define HCI_2DH5 0x1000
  448. #define HCI_3DH5 0x2000
  449. #define HCI_HV1 0x0020
  450. #define HCI_HV2 0x0040
  451. #define HCI_HV3 0x0080
  452. #define SCO_PTYPE_MASK (HCI_HV1 | HCI_HV2 | HCI_HV3)
  453. #define ACL_PTYPE_MASK (~SCO_PTYPE_MASK)
  454. /* eSCO packet types */
  455. #define ESCO_HV1 0x0001
  456. #define ESCO_HV2 0x0002
  457. #define ESCO_HV3 0x0004
  458. #define ESCO_EV3 0x0008
  459. #define ESCO_EV4 0x0010
  460. #define ESCO_EV5 0x0020
  461. #define ESCO_2EV3 0x0040
  462. #define ESCO_3EV3 0x0080
  463. #define ESCO_2EV5 0x0100
  464. #define ESCO_3EV5 0x0200
  465. #define SCO_ESCO_MASK (ESCO_HV1 | ESCO_HV2 | ESCO_HV3)
  466. #define EDR_ESCO_MASK (ESCO_2EV3 | ESCO_3EV3 | ESCO_2EV5 | ESCO_3EV5)
  467. /* ACL flags */
  468. #define ACL_START_NO_FLUSH 0x00
  469. #define ACL_CONT 0x01
  470. #define ACL_START 0x02
  471. #define ACL_COMPLETE 0x03
  472. #define ACL_ACTIVE_BCAST 0x04
  473. #define ACL_PICO_BCAST 0x08
  474. /* ISO PB flags */
  475. #define ISO_START 0x00
  476. #define ISO_CONT 0x01
  477. #define ISO_SINGLE 0x02
  478. #define ISO_END 0x03
  479. /* ISO TS flags */
  480. #define ISO_TS 0x01
  481. /* Baseband links */
  482. #define SCO_LINK 0x00
  483. #define ACL_LINK 0x01
  484. #define ESCO_LINK 0x02
  485. /* Low Energy links do not have defined link type. Use invented one */
  486. #define LE_LINK 0x80
  487. #define ISO_LINK 0x82
  488. #define INVALID_LINK 0xff
  489. /* LMP features */
  490. #define LMP_3SLOT 0x01
  491. #define LMP_5SLOT 0x02
  492. #define LMP_ENCRYPT 0x04
  493. #define LMP_SOFFSET 0x08
  494. #define LMP_TACCURACY 0x10
  495. #define LMP_RSWITCH 0x20
  496. #define LMP_HOLD 0x40
  497. #define LMP_SNIFF 0x80
  498. #define LMP_PARK 0x01
  499. #define LMP_RSSI 0x02
  500. #define LMP_QUALITY 0x04
  501. #define LMP_SCO 0x08
  502. #define LMP_HV2 0x10
  503. #define LMP_HV3 0x20
  504. #define LMP_ULAW 0x40
  505. #define LMP_ALAW 0x80
  506. #define LMP_CVSD 0x01
  507. #define LMP_PSCHEME 0x02
  508. #define LMP_PCONTROL 0x04
  509. #define LMP_TRANSPARENT 0x08
  510. #define LMP_EDR_2M 0x02
  511. #define LMP_EDR_3M 0x04
  512. #define LMP_RSSI_INQ 0x40
  513. #define LMP_ESCO 0x80
  514. #define LMP_EV4 0x01
  515. #define LMP_EV5 0x02
  516. #define LMP_NO_BREDR 0x20
  517. #define LMP_LE 0x40
  518. #define LMP_EDR_3SLOT 0x80
  519. #define LMP_EDR_5SLOT 0x01
  520. #define LMP_SNIFF_SUBR 0x02
  521. #define LMP_PAUSE_ENC 0x04
  522. #define LMP_EDR_ESCO_2M 0x20
  523. #define LMP_EDR_ESCO_3M 0x40
  524. #define LMP_EDR_3S_ESCO 0x80
  525. #define LMP_EXT_INQ 0x01
  526. #define LMP_SIMUL_LE_BR 0x02
  527. #define LMP_SIMPLE_PAIR 0x08
  528. #define LMP_ERR_DATA_REPORTING 0x20
  529. #define LMP_NO_FLUSH 0x40
  530. #define LMP_LSTO 0x01
  531. #define LMP_INQ_TX_PWR 0x02
  532. #define LMP_EXTFEATURES 0x80
  533. /* Extended LMP features */
  534. #define LMP_CPB_CENTRAL 0x01
  535. #define LMP_CPB_PERIPHERAL 0x02
  536. #define LMP_SYNC_TRAIN 0x04
  537. #define LMP_SYNC_SCAN 0x08
  538. #define LMP_SC 0x01
  539. #define LMP_PING 0x02
  540. /* Host features */
  541. #define LMP_HOST_SSP 0x01
  542. #define LMP_HOST_LE 0x02
  543. #define LMP_HOST_LE_BREDR 0x04
  544. #define LMP_HOST_SC 0x08
  545. /* LE features */
  546. #define HCI_LE_ENCRYPTION 0x01
  547. #define HCI_LE_CONN_PARAM_REQ_PROC 0x02
  548. #define HCI_LE_PERIPHERAL_FEATURES 0x08
  549. #define HCI_LE_PING 0x10
  550. #define HCI_LE_DATA_LEN_EXT 0x20
  551. #define HCI_LE_LL_PRIVACY 0x40
  552. #define HCI_LE_EXT_SCAN_POLICY 0x80
  553. #define HCI_LE_PHY_2M 0x01
  554. #define HCI_LE_PHY_CODED 0x08
  555. #define HCI_LE_EXT_ADV 0x10
  556. #define HCI_LE_PERIODIC_ADV 0x20
  557. #define HCI_LE_CHAN_SEL_ALG2 0x40
  558. #define HCI_LE_CIS_CENTRAL 0x10
  559. #define HCI_LE_CIS_PERIPHERAL 0x20
  560. #define HCI_LE_ISO_BROADCASTER 0x40
  561. #define HCI_LE_ISO_SYNC_RECEIVER 0x80
  562. /* Connection modes */
  563. #define HCI_CM_ACTIVE 0x0000
  564. #define HCI_CM_HOLD 0x0001
  565. #define HCI_CM_SNIFF 0x0002
  566. #define HCI_CM_PARK 0x0003
  567. /* Link policies */
  568. #define HCI_LP_RSWITCH 0x0001
  569. #define HCI_LP_HOLD 0x0002
  570. #define HCI_LP_SNIFF 0x0004
  571. #define HCI_LP_PARK 0x0008
  572. /* Link modes */
  573. #define HCI_LM_ACCEPT 0x8000
  574. #define HCI_LM_MASTER 0x0001
  575. #define HCI_LM_AUTH 0x0002
  576. #define HCI_LM_ENCRYPT 0x0004
  577. #define HCI_LM_TRUSTED 0x0008
  578. #define HCI_LM_RELIABLE 0x0010
  579. #define HCI_LM_SECURE 0x0020
  580. #define HCI_LM_FIPS 0x0040
  581. /* Authentication types */
  582. #define HCI_AT_NO_BONDING 0x00
  583. #define HCI_AT_NO_BONDING_MITM 0x01
  584. #define HCI_AT_DEDICATED_BONDING 0x02
  585. #define HCI_AT_DEDICATED_BONDING_MITM 0x03
  586. #define HCI_AT_GENERAL_BONDING 0x04
  587. #define HCI_AT_GENERAL_BONDING_MITM 0x05
  588. /* I/O capabilities */
  589. #define HCI_IO_DISPLAY_ONLY 0x00
  590. #define HCI_IO_DISPLAY_YESNO 0x01
  591. #define HCI_IO_KEYBOARD_ONLY 0x02
  592. #define HCI_IO_NO_INPUT_OUTPUT 0x03
  593. /* Link Key types */
  594. #define HCI_LK_COMBINATION 0x00
  595. #define HCI_LK_LOCAL_UNIT 0x01
  596. #define HCI_LK_REMOTE_UNIT 0x02
  597. #define HCI_LK_DEBUG_COMBINATION 0x03
  598. #define HCI_LK_UNAUTH_COMBINATION_P192 0x04
  599. #define HCI_LK_AUTH_COMBINATION_P192 0x05
  600. #define HCI_LK_CHANGED_COMBINATION 0x06
  601. #define HCI_LK_UNAUTH_COMBINATION_P256 0x07
  602. #define HCI_LK_AUTH_COMBINATION_P256 0x08
  603. /* ---- HCI Error Codes ---- */
  604. #define HCI_ERROR_UNKNOWN_CONN_ID 0x02
  605. #define HCI_ERROR_AUTH_FAILURE 0x05
  606. #define HCI_ERROR_PIN_OR_KEY_MISSING 0x06
  607. #define HCI_ERROR_MEMORY_EXCEEDED 0x07
  608. #define HCI_ERROR_CONNECTION_TIMEOUT 0x08
  609. #define HCI_ERROR_COMMAND_DISALLOWED 0x0c
  610. #define HCI_ERROR_REJ_LIMITED_RESOURCES 0x0d
  611. #define HCI_ERROR_REJ_BAD_ADDR 0x0f
  612. #define HCI_ERROR_INVALID_PARAMETERS 0x12
  613. #define HCI_ERROR_REMOTE_USER_TERM 0x13
  614. #define HCI_ERROR_REMOTE_LOW_RESOURCES 0x14
  615. #define HCI_ERROR_REMOTE_POWER_OFF 0x15
  616. #define HCI_ERROR_LOCAL_HOST_TERM 0x16
  617. #define HCI_ERROR_PAIRING_NOT_ALLOWED 0x18
  618. #define HCI_ERROR_UNSUPPORTED_REMOTE_FEATURE 0x1a
  619. #define HCI_ERROR_INVALID_LL_PARAMS 0x1e
  620. #define HCI_ERROR_UNSPECIFIED 0x1f
  621. #define HCI_ERROR_ADVERTISING_TIMEOUT 0x3c
  622. #define HCI_ERROR_CANCELLED_BY_HOST 0x44
  623. /* Flow control modes */
  624. #define HCI_FLOW_CTL_MODE_PACKET_BASED 0x00
  625. #define HCI_FLOW_CTL_MODE_BLOCK_BASED 0x01
  626. /* The core spec defines 127 as the "not available" value */
  627. #define HCI_TX_POWER_INVALID 127
  628. #define HCI_RSSI_INVALID 127
  629. #define HCI_SYNC_HANDLE_INVALID 0xffff
  630. #define HCI_SID_INVALID 0xff
  631. #define HCI_ROLE_MASTER 0x00
  632. #define HCI_ROLE_SLAVE 0x01
  633. /* Extended Inquiry Response field types */
  634. #define EIR_FLAGS 0x01 /* flags */
  635. #define EIR_UUID16_SOME 0x02 /* 16-bit UUID, more available */
  636. #define EIR_UUID16_ALL 0x03 /* 16-bit UUID, all listed */
  637. #define EIR_UUID32_SOME 0x04 /* 32-bit UUID, more available */
  638. #define EIR_UUID32_ALL 0x05 /* 32-bit UUID, all listed */
  639. #define EIR_UUID128_SOME 0x06 /* 128-bit UUID, more available */
  640. #define EIR_UUID128_ALL 0x07 /* 128-bit UUID, all listed */
  641. #define EIR_NAME_SHORT 0x08 /* shortened local name */
  642. #define EIR_NAME_COMPLETE 0x09 /* complete local name */
  643. #define EIR_TX_POWER 0x0A /* transmit power level */
  644. #define EIR_CLASS_OF_DEV 0x0D /* Class of Device */
  645. #define EIR_SSP_HASH_C192 0x0E /* Simple Pairing Hash C-192 */
  646. #define EIR_SSP_RAND_R192 0x0F /* Simple Pairing Randomizer R-192 */
  647. #define EIR_DEVICE_ID 0x10 /* device ID */
  648. #define EIR_APPEARANCE 0x19 /* Device appearance */
  649. #define EIR_SERVICE_DATA 0x16 /* Service Data */
  650. #define EIR_LE_BDADDR 0x1B /* LE Bluetooth device address */
  651. #define EIR_LE_ROLE 0x1C /* LE role */
  652. #define EIR_SSP_HASH_C256 0x1D /* Simple Pairing Hash C-256 */
  653. #define EIR_SSP_RAND_R256 0x1E /* Simple Pairing Rand R-256 */
  654. #define EIR_LE_SC_CONFIRM 0x22 /* LE SC Confirmation Value */
  655. #define EIR_LE_SC_RANDOM 0x23 /* LE SC Random Value */
  656. /* Low Energy Advertising Flags */
  657. #define LE_AD_LIMITED 0x01 /* Limited Discoverable */
  658. #define LE_AD_GENERAL 0x02 /* General Discoverable */
  659. #define LE_AD_NO_BREDR 0x04 /* BR/EDR not supported */
  660. #define LE_AD_SIM_LE_BREDR_CTRL 0x08 /* Simultaneous LE & BR/EDR Controller */
  661. #define LE_AD_SIM_LE_BREDR_HOST 0x10 /* Simultaneous LE & BR/EDR Host */
  662. /* ----- HCI Commands ---- */
  663. #define HCI_OP_NOP 0x0000
  664. #define HCI_OP_INQUIRY 0x0401
  665. struct hci_cp_inquiry {
  666. __u8 lap[3];
  667. __u8 length;
  668. __u8 num_rsp;
  669. } __packed;
  670. #define HCI_OP_INQUIRY_CANCEL 0x0402
  671. #define HCI_OP_PERIODIC_INQ 0x0403
  672. #define HCI_OP_EXIT_PERIODIC_INQ 0x0404
  673. #define HCI_OP_CREATE_CONN 0x0405
  674. struct hci_cp_create_conn {
  675. bdaddr_t bdaddr;
  676. __le16 pkt_type;
  677. __u8 pscan_rep_mode;
  678. __u8 pscan_mode;
  679. __le16 clock_offset;
  680. __u8 role_switch;
  681. } __packed;
  682. #define HCI_OP_DISCONNECT 0x0406
  683. struct hci_cp_disconnect {
  684. __le16 handle;
  685. __u8 reason;
  686. } __packed;
  687. #define HCI_OP_ADD_SCO 0x0407
  688. struct hci_cp_add_sco {
  689. __le16 handle;
  690. __le16 pkt_type;
  691. } __packed;
  692. #define HCI_OP_CREATE_CONN_CANCEL 0x0408
  693. struct hci_cp_create_conn_cancel {
  694. bdaddr_t bdaddr;
  695. } __packed;
  696. #define HCI_OP_ACCEPT_CONN_REQ 0x0409
  697. struct hci_cp_accept_conn_req {
  698. bdaddr_t bdaddr;
  699. __u8 role;
  700. } __packed;
  701. #define HCI_OP_REJECT_CONN_REQ 0x040a
  702. struct hci_cp_reject_conn_req {
  703. bdaddr_t bdaddr;
  704. __u8 reason;
  705. } __packed;
  706. #define HCI_OP_LINK_KEY_REPLY 0x040b
  707. struct hci_cp_link_key_reply {
  708. bdaddr_t bdaddr;
  709. __u8 link_key[HCI_LINK_KEY_SIZE];
  710. } __packed;
  711. #define HCI_OP_LINK_KEY_NEG_REPLY 0x040c
  712. struct hci_cp_link_key_neg_reply {
  713. bdaddr_t bdaddr;
  714. } __packed;
  715. #define HCI_OP_PIN_CODE_REPLY 0x040d
  716. struct hci_cp_pin_code_reply {
  717. bdaddr_t bdaddr;
  718. __u8 pin_len;
  719. __u8 pin_code[16];
  720. } __packed;
  721. struct hci_rp_pin_code_reply {
  722. __u8 status;
  723. bdaddr_t bdaddr;
  724. } __packed;
  725. #define HCI_OP_PIN_CODE_NEG_REPLY 0x040e
  726. struct hci_cp_pin_code_neg_reply {
  727. bdaddr_t bdaddr;
  728. } __packed;
  729. struct hci_rp_pin_code_neg_reply {
  730. __u8 status;
  731. bdaddr_t bdaddr;
  732. } __packed;
  733. #define HCI_OP_CHANGE_CONN_PTYPE 0x040f
  734. struct hci_cp_change_conn_ptype {
  735. __le16 handle;
  736. __le16 pkt_type;
  737. } __packed;
  738. #define HCI_OP_AUTH_REQUESTED 0x0411
  739. struct hci_cp_auth_requested {
  740. __le16 handle;
  741. } __packed;
  742. #define HCI_OP_SET_CONN_ENCRYPT 0x0413
  743. struct hci_cp_set_conn_encrypt {
  744. __le16 handle;
  745. __u8 encrypt;
  746. } __packed;
  747. #define HCI_OP_CHANGE_CONN_LINK_KEY 0x0415
  748. struct hci_cp_change_conn_link_key {
  749. __le16 handle;
  750. } __packed;
  751. #define HCI_OP_REMOTE_NAME_REQ 0x0419
  752. struct hci_cp_remote_name_req {
  753. bdaddr_t bdaddr;
  754. __u8 pscan_rep_mode;
  755. __u8 pscan_mode;
  756. __le16 clock_offset;
  757. } __packed;
  758. #define HCI_OP_REMOTE_NAME_REQ_CANCEL 0x041a
  759. struct hci_cp_remote_name_req_cancel {
  760. bdaddr_t bdaddr;
  761. } __packed;
  762. #define HCI_OP_READ_REMOTE_FEATURES 0x041b
  763. struct hci_cp_read_remote_features {
  764. __le16 handle;
  765. } __packed;
  766. #define HCI_OP_READ_REMOTE_EXT_FEATURES 0x041c
  767. struct hci_cp_read_remote_ext_features {
  768. __le16 handle;
  769. __u8 page;
  770. } __packed;
  771. #define HCI_OP_READ_REMOTE_VERSION 0x041d
  772. struct hci_cp_read_remote_version {
  773. __le16 handle;
  774. } __packed;
  775. #define HCI_OP_READ_CLOCK_OFFSET 0x041f
  776. struct hci_cp_read_clock_offset {
  777. __le16 handle;
  778. } __packed;
  779. #define HCI_OP_SETUP_SYNC_CONN 0x0428
  780. struct hci_cp_setup_sync_conn {
  781. __le16 handle;
  782. __le32 tx_bandwidth;
  783. __le32 rx_bandwidth;
  784. __le16 max_latency;
  785. __le16 voice_setting;
  786. __u8 retrans_effort;
  787. __le16 pkt_type;
  788. } __packed;
  789. #define HCI_OP_ACCEPT_SYNC_CONN_REQ 0x0429
  790. struct hci_cp_accept_sync_conn_req {
  791. bdaddr_t bdaddr;
  792. __le32 tx_bandwidth;
  793. __le32 rx_bandwidth;
  794. __le16 max_latency;
  795. __le16 content_format;
  796. __u8 retrans_effort;
  797. __le16 pkt_type;
  798. } __packed;
  799. #define HCI_OP_REJECT_SYNC_CONN_REQ 0x042a
  800. struct hci_cp_reject_sync_conn_req {
  801. bdaddr_t bdaddr;
  802. __u8 reason;
  803. } __packed;
  804. #define HCI_OP_IO_CAPABILITY_REPLY 0x042b
  805. struct hci_cp_io_capability_reply {
  806. bdaddr_t bdaddr;
  807. __u8 capability;
  808. __u8 oob_data;
  809. __u8 authentication;
  810. } __packed;
  811. #define HCI_OP_USER_CONFIRM_REPLY 0x042c
  812. struct hci_cp_user_confirm_reply {
  813. bdaddr_t bdaddr;
  814. } __packed;
  815. struct hci_rp_user_confirm_reply {
  816. __u8 status;
  817. bdaddr_t bdaddr;
  818. } __packed;
  819. #define HCI_OP_USER_CONFIRM_NEG_REPLY 0x042d
  820. #define HCI_OP_USER_PASSKEY_REPLY 0x042e
  821. struct hci_cp_user_passkey_reply {
  822. bdaddr_t bdaddr;
  823. __le32 passkey;
  824. } __packed;
  825. #define HCI_OP_USER_PASSKEY_NEG_REPLY 0x042f
  826. #define HCI_OP_REMOTE_OOB_DATA_REPLY 0x0430
  827. struct hci_cp_remote_oob_data_reply {
  828. bdaddr_t bdaddr;
  829. __u8 hash[16];
  830. __u8 rand[16];
  831. } __packed;
  832. #define HCI_OP_REMOTE_OOB_DATA_NEG_REPLY 0x0433
  833. struct hci_cp_remote_oob_data_neg_reply {
  834. bdaddr_t bdaddr;
  835. } __packed;
  836. #define HCI_OP_IO_CAPABILITY_NEG_REPLY 0x0434
  837. struct hci_cp_io_capability_neg_reply {
  838. bdaddr_t bdaddr;
  839. __u8 reason;
  840. } __packed;
  841. #define HCI_OP_ENHANCED_SETUP_SYNC_CONN 0x043d
  842. struct hci_coding_format {
  843. __u8 id;
  844. __le16 cid;
  845. __le16 vid;
  846. } __packed;
  847. struct hci_cp_enhanced_setup_sync_conn {
  848. __le16 handle;
  849. __le32 tx_bandwidth;
  850. __le32 rx_bandwidth;
  851. struct hci_coding_format tx_coding_format;
  852. struct hci_coding_format rx_coding_format;
  853. __le16 tx_codec_frame_size;
  854. __le16 rx_codec_frame_size;
  855. __le32 in_bandwidth;
  856. __le32 out_bandwidth;
  857. struct hci_coding_format in_coding_format;
  858. struct hci_coding_format out_coding_format;
  859. __le16 in_coded_data_size;
  860. __le16 out_coded_data_size;
  861. __u8 in_pcm_data_format;
  862. __u8 out_pcm_data_format;
  863. __u8 in_pcm_sample_payload_msb_pos;
  864. __u8 out_pcm_sample_payload_msb_pos;
  865. __u8 in_data_path;
  866. __u8 out_data_path;
  867. __u8 in_transport_unit_size;
  868. __u8 out_transport_unit_size;
  869. __le16 max_latency;
  870. __le16 pkt_type;
  871. __u8 retrans_effort;
  872. } __packed;
  873. struct hci_rp_logical_link_cancel {
  874. __u8 status;
  875. __u8 phy_handle;
  876. __u8 flow_spec_id;
  877. } __packed;
  878. #define HCI_OP_SET_CPB 0x0441
  879. struct hci_cp_set_cpb {
  880. __u8 enable;
  881. __u8 lt_addr;
  882. __u8 lpo_allowed;
  883. __le16 packet_type;
  884. __le16 interval_min;
  885. __le16 interval_max;
  886. __le16 cpb_sv_tout;
  887. } __packed;
  888. struct hci_rp_set_cpb {
  889. __u8 status;
  890. __u8 lt_addr;
  891. __le16 interval;
  892. } __packed;
  893. #define HCI_OP_START_SYNC_TRAIN 0x0443
  894. #define HCI_OP_REMOTE_OOB_EXT_DATA_REPLY 0x0445
  895. struct hci_cp_remote_oob_ext_data_reply {
  896. bdaddr_t bdaddr;
  897. __u8 hash192[16];
  898. __u8 rand192[16];
  899. __u8 hash256[16];
  900. __u8 rand256[16];
  901. } __packed;
  902. #define HCI_OP_SNIFF_MODE 0x0803
  903. struct hci_cp_sniff_mode {
  904. __le16 handle;
  905. __le16 max_interval;
  906. __le16 min_interval;
  907. __le16 attempt;
  908. __le16 timeout;
  909. } __packed;
  910. #define HCI_OP_EXIT_SNIFF_MODE 0x0804
  911. struct hci_cp_exit_sniff_mode {
  912. __le16 handle;
  913. } __packed;
  914. #define HCI_OP_ROLE_DISCOVERY 0x0809
  915. struct hci_cp_role_discovery {
  916. __le16 handle;
  917. } __packed;
  918. struct hci_rp_role_discovery {
  919. __u8 status;
  920. __le16 handle;
  921. __u8 role;
  922. } __packed;
  923. #define HCI_OP_SWITCH_ROLE 0x080b
  924. struct hci_cp_switch_role {
  925. bdaddr_t bdaddr;
  926. __u8 role;
  927. } __packed;
  928. #define HCI_OP_READ_LINK_POLICY 0x080c
  929. struct hci_cp_read_link_policy {
  930. __le16 handle;
  931. } __packed;
  932. struct hci_rp_read_link_policy {
  933. __u8 status;
  934. __le16 handle;
  935. __le16 policy;
  936. } __packed;
  937. #define HCI_OP_WRITE_LINK_POLICY 0x080d
  938. struct hci_cp_write_link_policy {
  939. __le16 handle;
  940. __le16 policy;
  941. } __packed;
  942. struct hci_rp_write_link_policy {
  943. __u8 status;
  944. __le16 handle;
  945. } __packed;
  946. #define HCI_OP_READ_DEF_LINK_POLICY 0x080e
  947. struct hci_rp_read_def_link_policy {
  948. __u8 status;
  949. __le16 policy;
  950. } __packed;
  951. #define HCI_OP_WRITE_DEF_LINK_POLICY 0x080f
  952. struct hci_cp_write_def_link_policy {
  953. __le16 policy;
  954. } __packed;
  955. #define HCI_OP_SNIFF_SUBRATE 0x0811
  956. struct hci_cp_sniff_subrate {
  957. __le16 handle;
  958. __le16 max_latency;
  959. __le16 min_remote_timeout;
  960. __le16 min_local_timeout;
  961. } __packed;
  962. #define HCI_OP_SET_EVENT_MASK 0x0c01
  963. #define HCI_OP_RESET 0x0c03
  964. #define HCI_OP_SET_EVENT_FLT 0x0c05
  965. #define HCI_SET_EVENT_FLT_SIZE 9
  966. struct hci_cp_set_event_filter {
  967. __u8 flt_type;
  968. __u8 cond_type;
  969. struct {
  970. bdaddr_t bdaddr;
  971. __u8 auto_accept;
  972. } __packed addr_conn_flt;
  973. } __packed;
  974. /* Filter types */
  975. #define HCI_FLT_CLEAR_ALL 0x00
  976. #define HCI_FLT_INQ_RESULT 0x01
  977. #define HCI_FLT_CONN_SETUP 0x02
  978. /* CONN_SETUP Condition types */
  979. #define HCI_CONN_SETUP_ALLOW_ALL 0x00
  980. #define HCI_CONN_SETUP_ALLOW_CLASS 0x01
  981. #define HCI_CONN_SETUP_ALLOW_BDADDR 0x02
  982. /* CONN_SETUP Conditions */
  983. #define HCI_CONN_SETUP_AUTO_OFF 0x01
  984. #define HCI_CONN_SETUP_AUTO_ON 0x02
  985. #define HCI_CONN_SETUP_AUTO_ON_WITH_RS 0x03
  986. #define HCI_OP_READ_STORED_LINK_KEY 0x0c0d
  987. struct hci_cp_read_stored_link_key {
  988. bdaddr_t bdaddr;
  989. __u8 read_all;
  990. } __packed;
  991. struct hci_rp_read_stored_link_key {
  992. __u8 status;
  993. __le16 max_keys;
  994. __le16 num_keys;
  995. } __packed;
  996. #define HCI_OP_DELETE_STORED_LINK_KEY 0x0c12
  997. struct hci_cp_delete_stored_link_key {
  998. bdaddr_t bdaddr;
  999. __u8 delete_all;
  1000. } __packed;
  1001. struct hci_rp_delete_stored_link_key {
  1002. __u8 status;
  1003. __le16 num_keys;
  1004. } __packed;
  1005. #define HCI_MAX_NAME_LENGTH 248
  1006. #define HCI_OP_WRITE_LOCAL_NAME 0x0c13
  1007. struct hci_cp_write_local_name {
  1008. __u8 name[HCI_MAX_NAME_LENGTH];
  1009. } __packed;
  1010. #define HCI_OP_READ_LOCAL_NAME 0x0c14
  1011. struct hci_rp_read_local_name {
  1012. __u8 status;
  1013. __u8 name[HCI_MAX_NAME_LENGTH];
  1014. } __packed;
  1015. #define HCI_OP_WRITE_CA_TIMEOUT 0x0c16
  1016. #define HCI_OP_WRITE_PG_TIMEOUT 0x0c18
  1017. #define HCI_OP_WRITE_SCAN_ENABLE 0x0c1a
  1018. #define SCAN_DISABLED 0x00
  1019. #define SCAN_INQUIRY 0x01
  1020. #define SCAN_PAGE 0x02
  1021. #define HCI_OP_READ_AUTH_ENABLE 0x0c1f
  1022. #define HCI_OP_WRITE_AUTH_ENABLE 0x0c20
  1023. #define AUTH_DISABLED 0x00
  1024. #define AUTH_ENABLED 0x01
  1025. #define HCI_OP_READ_ENCRYPT_MODE 0x0c21
  1026. #define HCI_OP_WRITE_ENCRYPT_MODE 0x0c22
  1027. #define ENCRYPT_DISABLED 0x00
  1028. #define ENCRYPT_P2P 0x01
  1029. #define ENCRYPT_BOTH 0x02
  1030. #define HCI_OP_READ_CLASS_OF_DEV 0x0c23
  1031. struct hci_rp_read_class_of_dev {
  1032. __u8 status;
  1033. __u8 dev_class[3];
  1034. } __packed;
  1035. #define HCI_OP_WRITE_CLASS_OF_DEV 0x0c24
  1036. struct hci_cp_write_class_of_dev {
  1037. __u8 dev_class[3];
  1038. } __packed;
  1039. #define HCI_OP_READ_VOICE_SETTING 0x0c25
  1040. struct hci_rp_read_voice_setting {
  1041. __u8 status;
  1042. __le16 voice_setting;
  1043. } __packed;
  1044. #define HCI_OP_WRITE_VOICE_SETTING 0x0c26
  1045. struct hci_cp_write_voice_setting {
  1046. __le16 voice_setting;
  1047. } __packed;
  1048. #define HCI_OP_HOST_BUFFER_SIZE 0x0c33
  1049. struct hci_cp_host_buffer_size {
  1050. __le16 acl_mtu;
  1051. __u8 sco_mtu;
  1052. __le16 acl_max_pkt;
  1053. __le16 sco_max_pkt;
  1054. } __packed;
  1055. #define HCI_OP_READ_NUM_SUPPORTED_IAC 0x0c38
  1056. struct hci_rp_read_num_supported_iac {
  1057. __u8 status;
  1058. __u8 num_iac;
  1059. } __packed;
  1060. #define HCI_OP_READ_CURRENT_IAC_LAP 0x0c39
  1061. #define HCI_OP_WRITE_CURRENT_IAC_LAP 0x0c3a
  1062. struct hci_cp_write_current_iac_lap {
  1063. __u8 num_iac;
  1064. __u8 iac_lap[6];
  1065. } __packed;
  1066. #define HCI_OP_WRITE_INQUIRY_MODE 0x0c45
  1067. #define HCI_MAX_EIR_LENGTH 240
  1068. #define HCI_OP_WRITE_EIR 0x0c52
  1069. struct hci_cp_write_eir {
  1070. __u8 fec;
  1071. __u8 data[HCI_MAX_EIR_LENGTH];
  1072. } __packed;
  1073. #define HCI_OP_READ_SSP_MODE 0x0c55
  1074. struct hci_rp_read_ssp_mode {
  1075. __u8 status;
  1076. __u8 mode;
  1077. } __packed;
  1078. #define HCI_OP_WRITE_SSP_MODE 0x0c56
  1079. struct hci_cp_write_ssp_mode {
  1080. __u8 mode;
  1081. } __packed;
  1082. #define HCI_OP_READ_LOCAL_OOB_DATA 0x0c57
  1083. struct hci_rp_read_local_oob_data {
  1084. __u8 status;
  1085. __u8 hash[16];
  1086. __u8 rand[16];
  1087. } __packed;
  1088. #define HCI_OP_READ_INQ_RSP_TX_POWER 0x0c58
  1089. struct hci_rp_read_inq_rsp_tx_power {
  1090. __u8 status;
  1091. __s8 tx_power;
  1092. } __packed;
  1093. #define HCI_OP_READ_DEF_ERR_DATA_REPORTING 0x0c5a
  1094. #define ERR_DATA_REPORTING_DISABLED 0x00
  1095. #define ERR_DATA_REPORTING_ENABLED 0x01
  1096. struct hci_rp_read_def_err_data_reporting {
  1097. __u8 status;
  1098. __u8 err_data_reporting;
  1099. } __packed;
  1100. #define HCI_OP_WRITE_DEF_ERR_DATA_REPORTING 0x0c5b
  1101. struct hci_cp_write_def_err_data_reporting {
  1102. __u8 err_data_reporting;
  1103. } __packed;
  1104. #define HCI_OP_SET_EVENT_MASK_PAGE_2 0x0c63
  1105. #define HCI_OP_READ_LOCATION_DATA 0x0c64
  1106. #define HCI_OP_READ_FLOW_CONTROL_MODE 0x0c66
  1107. struct hci_rp_read_flow_control_mode {
  1108. __u8 status;
  1109. __u8 mode;
  1110. } __packed;
  1111. #define HCI_OP_WRITE_LE_HOST_SUPPORTED 0x0c6d
  1112. struct hci_cp_write_le_host_supported {
  1113. __u8 le;
  1114. __u8 simul;
  1115. } __packed;
  1116. #define HCI_OP_SET_RESERVED_LT_ADDR 0x0c74
  1117. struct hci_cp_set_reserved_lt_addr {
  1118. __u8 lt_addr;
  1119. } __packed;
  1120. struct hci_rp_set_reserved_lt_addr {
  1121. __u8 status;
  1122. __u8 lt_addr;
  1123. } __packed;
  1124. #define HCI_OP_DELETE_RESERVED_LT_ADDR 0x0c75
  1125. struct hci_cp_delete_reserved_lt_addr {
  1126. __u8 lt_addr;
  1127. } __packed;
  1128. struct hci_rp_delete_reserved_lt_addr {
  1129. __u8 status;
  1130. __u8 lt_addr;
  1131. } __packed;
  1132. #define HCI_OP_SET_CPB_DATA 0x0c76
  1133. struct hci_cp_set_cpb_data {
  1134. __u8 lt_addr;
  1135. __u8 fragment;
  1136. __u8 data_length;
  1137. __u8 data[HCI_MAX_CPB_DATA_SIZE];
  1138. } __packed;
  1139. struct hci_rp_set_cpb_data {
  1140. __u8 status;
  1141. __u8 lt_addr;
  1142. } __packed;
  1143. #define HCI_OP_READ_SYNC_TRAIN_PARAMS 0x0c77
  1144. #define HCI_OP_WRITE_SYNC_TRAIN_PARAMS 0x0c78
  1145. struct hci_cp_write_sync_train_params {
  1146. __le16 interval_min;
  1147. __le16 interval_max;
  1148. __le32 sync_train_tout;
  1149. __u8 service_data;
  1150. } __packed;
  1151. struct hci_rp_write_sync_train_params {
  1152. __u8 status;
  1153. __le16 sync_train_int;
  1154. } __packed;
  1155. #define HCI_OP_READ_SC_SUPPORT 0x0c79
  1156. struct hci_rp_read_sc_support {
  1157. __u8 status;
  1158. __u8 support;
  1159. } __packed;
  1160. #define HCI_OP_WRITE_SC_SUPPORT 0x0c7a
  1161. struct hci_cp_write_sc_support {
  1162. __u8 support;
  1163. } __packed;
  1164. #define HCI_OP_READ_AUTH_PAYLOAD_TO 0x0c7b
  1165. struct hci_cp_read_auth_payload_to {
  1166. __le16 handle;
  1167. } __packed;
  1168. struct hci_rp_read_auth_payload_to {
  1169. __u8 status;
  1170. __le16 handle;
  1171. __le16 timeout;
  1172. } __packed;
  1173. #define HCI_OP_WRITE_AUTH_PAYLOAD_TO 0x0c7c
  1174. struct hci_cp_write_auth_payload_to {
  1175. __le16 handle;
  1176. __le16 timeout;
  1177. } __packed;
  1178. struct hci_rp_write_auth_payload_to {
  1179. __u8 status;
  1180. __le16 handle;
  1181. } __packed;
  1182. #define HCI_OP_READ_LOCAL_OOB_EXT_DATA 0x0c7d
  1183. struct hci_rp_read_local_oob_ext_data {
  1184. __u8 status;
  1185. __u8 hash192[16];
  1186. __u8 rand192[16];
  1187. __u8 hash256[16];
  1188. __u8 rand256[16];
  1189. } __packed;
  1190. #define HCI_CONFIGURE_DATA_PATH 0x0c83
  1191. struct hci_op_configure_data_path {
  1192. __u8 direction;
  1193. __u8 data_path_id;
  1194. __u8 vnd_len;
  1195. __u8 vnd_data[];
  1196. } __packed;
  1197. #define HCI_OP_READ_LOCAL_VERSION 0x1001
  1198. struct hci_rp_read_local_version {
  1199. __u8 status;
  1200. __u8 hci_ver;
  1201. __le16 hci_rev;
  1202. __u8 lmp_ver;
  1203. __le16 manufacturer;
  1204. __le16 lmp_subver;
  1205. } __packed;
  1206. #define HCI_OP_READ_LOCAL_COMMANDS 0x1002
  1207. struct hci_rp_read_local_commands {
  1208. __u8 status;
  1209. __u8 commands[64];
  1210. } __packed;
  1211. #define HCI_OP_READ_LOCAL_FEATURES 0x1003
  1212. struct hci_rp_read_local_features {
  1213. __u8 status;
  1214. __u8 features[8];
  1215. } __packed;
  1216. #define HCI_OP_READ_LOCAL_EXT_FEATURES 0x1004
  1217. struct hci_cp_read_local_ext_features {
  1218. __u8 page;
  1219. } __packed;
  1220. struct hci_rp_read_local_ext_features {
  1221. __u8 status;
  1222. __u8 page;
  1223. __u8 max_page;
  1224. __u8 features[8];
  1225. } __packed;
  1226. #define HCI_OP_READ_BUFFER_SIZE 0x1005
  1227. struct hci_rp_read_buffer_size {
  1228. __u8 status;
  1229. __le16 acl_mtu;
  1230. __u8 sco_mtu;
  1231. __le16 acl_max_pkt;
  1232. __le16 sco_max_pkt;
  1233. } __packed;
  1234. #define HCI_OP_READ_BD_ADDR 0x1009
  1235. struct hci_rp_read_bd_addr {
  1236. __u8 status;
  1237. bdaddr_t bdaddr;
  1238. } __packed;
  1239. #define HCI_OP_READ_DATA_BLOCK_SIZE 0x100a
  1240. struct hci_rp_read_data_block_size {
  1241. __u8 status;
  1242. __le16 max_acl_len;
  1243. __le16 block_len;
  1244. __le16 num_blocks;
  1245. } __packed;
  1246. #define HCI_OP_READ_LOCAL_CODECS 0x100b
  1247. struct hci_std_codecs {
  1248. __u8 num;
  1249. __u8 codec[];
  1250. } __packed;
  1251. struct hci_vnd_codec {
  1252. /* company id */
  1253. __le16 cid;
  1254. /* vendor codec id */
  1255. __le16 vid;
  1256. } __packed;
  1257. struct hci_vnd_codecs {
  1258. __u8 num;
  1259. struct hci_vnd_codec codec[];
  1260. } __packed;
  1261. struct hci_rp_read_local_supported_codecs {
  1262. __u8 status;
  1263. struct hci_std_codecs std_codecs;
  1264. struct hci_vnd_codecs vnd_codecs;
  1265. } __packed;
  1266. #define HCI_OP_READ_LOCAL_PAIRING_OPTS 0x100c
  1267. struct hci_rp_read_local_pairing_opts {
  1268. __u8 status;
  1269. __u8 pairing_opts;
  1270. __u8 max_key_size;
  1271. } __packed;
  1272. #define HCI_OP_READ_LOCAL_CODECS_V2 0x100d
  1273. struct hci_std_codec_v2 {
  1274. __u8 id;
  1275. __u8 transport;
  1276. } __packed;
  1277. struct hci_std_codecs_v2 {
  1278. __u8 num;
  1279. struct hci_std_codec_v2 codec[];
  1280. } __packed;
  1281. struct hci_vnd_codec_v2 {
  1282. __le16 cid;
  1283. __le16 vid;
  1284. __u8 transport;
  1285. } __packed;
  1286. struct hci_vnd_codecs_v2 {
  1287. __u8 num;
  1288. struct hci_vnd_codec_v2 codec[];
  1289. } __packed;
  1290. struct hci_rp_read_local_supported_codecs_v2 {
  1291. __u8 status;
  1292. struct hci_std_codecs_v2 std_codecs;
  1293. struct hci_vnd_codecs_v2 vendor_codecs;
  1294. } __packed;
  1295. #define HCI_OP_READ_LOCAL_CODEC_CAPS 0x100e
  1296. struct hci_op_read_local_codec_caps {
  1297. __u8 id;
  1298. __le16 cid;
  1299. __le16 vid;
  1300. __u8 transport;
  1301. __u8 direction;
  1302. } __packed;
  1303. struct hci_codec_caps {
  1304. __u8 len;
  1305. __u8 data[];
  1306. } __packed;
  1307. struct hci_rp_read_local_codec_caps {
  1308. __u8 status;
  1309. __u8 num_caps;
  1310. } __packed;
  1311. #define HCI_OP_READ_PAGE_SCAN_ACTIVITY 0x0c1b
  1312. struct hci_rp_read_page_scan_activity {
  1313. __u8 status;
  1314. __le16 interval;
  1315. __le16 window;
  1316. } __packed;
  1317. #define HCI_OP_WRITE_PAGE_SCAN_ACTIVITY 0x0c1c
  1318. struct hci_cp_write_page_scan_activity {
  1319. __le16 interval;
  1320. __le16 window;
  1321. } __packed;
  1322. #define HCI_OP_READ_TX_POWER 0x0c2d
  1323. struct hci_cp_read_tx_power {
  1324. __le16 handle;
  1325. __u8 type;
  1326. } __packed;
  1327. struct hci_rp_read_tx_power {
  1328. __u8 status;
  1329. __le16 handle;
  1330. __s8 tx_power;
  1331. } __packed;
  1332. #define HCI_OP_READ_PAGE_SCAN_TYPE 0x0c46
  1333. struct hci_rp_read_page_scan_type {
  1334. __u8 status;
  1335. __u8 type;
  1336. } __packed;
  1337. #define HCI_OP_WRITE_PAGE_SCAN_TYPE 0x0c47
  1338. #define PAGE_SCAN_TYPE_STANDARD 0x00
  1339. #define PAGE_SCAN_TYPE_INTERLACED 0x01
  1340. #define HCI_OP_READ_RSSI 0x1405
  1341. struct hci_cp_read_rssi {
  1342. __le16 handle;
  1343. } __packed;
  1344. struct hci_rp_read_rssi {
  1345. __u8 status;
  1346. __le16 handle;
  1347. __s8 rssi;
  1348. } __packed;
  1349. #define HCI_OP_READ_CLOCK 0x1407
  1350. struct hci_cp_read_clock {
  1351. __le16 handle;
  1352. __u8 which;
  1353. } __packed;
  1354. struct hci_rp_read_clock {
  1355. __u8 status;
  1356. __le16 handle;
  1357. __le32 clock;
  1358. __le16 accuracy;
  1359. } __packed;
  1360. #define HCI_OP_READ_ENC_KEY_SIZE 0x1408
  1361. struct hci_cp_read_enc_key_size {
  1362. __le16 handle;
  1363. } __packed;
  1364. struct hci_rp_read_enc_key_size {
  1365. __u8 status;
  1366. __le16 handle;
  1367. __u8 key_size;
  1368. } __packed;
  1369. #define HCI_OP_GET_MWS_TRANSPORT_CONFIG 0x140c
  1370. #define HCI_OP_ENABLE_DUT_MODE 0x1803
  1371. #define HCI_OP_WRITE_SSP_DEBUG_MODE 0x1804
  1372. #define HCI_OP_LE_SET_EVENT_MASK 0x2001
  1373. struct hci_cp_le_set_event_mask {
  1374. __u8 mask[8];
  1375. } __packed;
  1376. /* BLUETOOTH CORE SPECIFICATION Version 5.4 | Vol 4, Part E
  1377. * 7.8.2 LE Read Buffer Size command
  1378. * MAX_LE_MTU is 0xffff.
  1379. * 0 is also valid. It means that no dedicated LE Buffer exists.
  1380. * It should use the HCI_Read_Buffer_Size command and mtu is shared
  1381. * between BR/EDR and LE.
  1382. */
  1383. #define HCI_MIN_LE_MTU 0x001b
  1384. #define HCI_OP_LE_READ_BUFFER_SIZE 0x2002
  1385. struct hci_rp_le_read_buffer_size {
  1386. __u8 status;
  1387. __le16 le_mtu;
  1388. __u8 le_max_pkt;
  1389. } __packed;
  1390. #define HCI_OP_LE_READ_LOCAL_FEATURES 0x2003
  1391. struct hci_rp_le_read_local_features {
  1392. __u8 status;
  1393. __u8 features[8];
  1394. } __packed;
  1395. #define HCI_OP_LE_SET_RANDOM_ADDR 0x2005
  1396. #define HCI_OP_LE_SET_ADV_PARAM 0x2006
  1397. struct hci_cp_le_set_adv_param {
  1398. __le16 min_interval;
  1399. __le16 max_interval;
  1400. __u8 type;
  1401. __u8 own_address_type;
  1402. __u8 direct_addr_type;
  1403. bdaddr_t direct_addr;
  1404. __u8 channel_map;
  1405. __u8 filter_policy;
  1406. } __packed;
  1407. #define HCI_OP_LE_READ_ADV_TX_POWER 0x2007
  1408. struct hci_rp_le_read_adv_tx_power {
  1409. __u8 status;
  1410. __s8 tx_power;
  1411. } __packed;
  1412. #define HCI_MAX_AD_LENGTH 31
  1413. #define HCI_OP_LE_SET_ADV_DATA 0x2008
  1414. struct hci_cp_le_set_adv_data {
  1415. __u8 length;
  1416. __u8 data[HCI_MAX_AD_LENGTH];
  1417. } __packed;
  1418. #define HCI_OP_LE_SET_SCAN_RSP_DATA 0x2009
  1419. struct hci_cp_le_set_scan_rsp_data {
  1420. __u8 length;
  1421. __u8 data[HCI_MAX_AD_LENGTH];
  1422. } __packed;
  1423. #define HCI_OP_LE_SET_ADV_ENABLE 0x200a
  1424. #define LE_SCAN_PASSIVE 0x00
  1425. #define LE_SCAN_ACTIVE 0x01
  1426. #define HCI_OP_LE_SET_SCAN_PARAM 0x200b
  1427. struct hci_cp_le_set_scan_param {
  1428. __u8 type;
  1429. __le16 interval;
  1430. __le16 window;
  1431. __u8 own_address_type;
  1432. __u8 filter_policy;
  1433. } __packed;
  1434. #define LE_SCAN_DISABLE 0x00
  1435. #define LE_SCAN_ENABLE 0x01
  1436. #define LE_SCAN_FILTER_DUP_DISABLE 0x00
  1437. #define LE_SCAN_FILTER_DUP_ENABLE 0x01
  1438. #define HCI_OP_LE_SET_SCAN_ENABLE 0x200c
  1439. struct hci_cp_le_set_scan_enable {
  1440. __u8 enable;
  1441. __u8 filter_dup;
  1442. } __packed;
  1443. #define HCI_LE_USE_PEER_ADDR 0x00
  1444. #define HCI_LE_USE_ACCEPT_LIST 0x01
  1445. #define HCI_OP_LE_CREATE_CONN 0x200d
  1446. struct hci_cp_le_create_conn {
  1447. __le16 scan_interval;
  1448. __le16 scan_window;
  1449. __u8 filter_policy;
  1450. __u8 peer_addr_type;
  1451. bdaddr_t peer_addr;
  1452. __u8 own_address_type;
  1453. __le16 conn_interval_min;
  1454. __le16 conn_interval_max;
  1455. __le16 conn_latency;
  1456. __le16 supervision_timeout;
  1457. __le16 min_ce_len;
  1458. __le16 max_ce_len;
  1459. } __packed;
  1460. #define HCI_OP_LE_CREATE_CONN_CANCEL 0x200e
  1461. #define HCI_OP_LE_READ_ACCEPT_LIST_SIZE 0x200f
  1462. struct hci_rp_le_read_accept_list_size {
  1463. __u8 status;
  1464. __u8 size;
  1465. } __packed;
  1466. #define HCI_OP_LE_CLEAR_ACCEPT_LIST 0x2010
  1467. #define HCI_OP_LE_ADD_TO_ACCEPT_LIST 0x2011
  1468. struct hci_cp_le_add_to_accept_list {
  1469. __u8 bdaddr_type;
  1470. bdaddr_t bdaddr;
  1471. } __packed;
  1472. #define HCI_OP_LE_DEL_FROM_ACCEPT_LIST 0x2012
  1473. struct hci_cp_le_del_from_accept_list {
  1474. __u8 bdaddr_type;
  1475. bdaddr_t bdaddr;
  1476. } __packed;
  1477. #define HCI_OP_LE_CONN_UPDATE 0x2013
  1478. struct hci_cp_le_conn_update {
  1479. __le16 handle;
  1480. __le16 conn_interval_min;
  1481. __le16 conn_interval_max;
  1482. __le16 conn_latency;
  1483. __le16 supervision_timeout;
  1484. __le16 min_ce_len;
  1485. __le16 max_ce_len;
  1486. } __packed;
  1487. #define HCI_OP_LE_READ_REMOTE_FEATURES 0x2016
  1488. struct hci_cp_le_read_remote_features {
  1489. __le16 handle;
  1490. } __packed;
  1491. #define HCI_OP_LE_START_ENC 0x2019
  1492. struct hci_cp_le_start_enc {
  1493. __le16 handle;
  1494. __le64 rand;
  1495. __le16 ediv;
  1496. __u8 ltk[16];
  1497. } __packed;
  1498. #define HCI_OP_LE_LTK_REPLY 0x201a
  1499. struct hci_cp_le_ltk_reply {
  1500. __le16 handle;
  1501. __u8 ltk[16];
  1502. } __packed;
  1503. struct hci_rp_le_ltk_reply {
  1504. __u8 status;
  1505. __le16 handle;
  1506. } __packed;
  1507. #define HCI_OP_LE_LTK_NEG_REPLY 0x201b
  1508. struct hci_cp_le_ltk_neg_reply {
  1509. __le16 handle;
  1510. } __packed;
  1511. struct hci_rp_le_ltk_neg_reply {
  1512. __u8 status;
  1513. __le16 handle;
  1514. } __packed;
  1515. #define HCI_OP_LE_READ_SUPPORTED_STATES 0x201c
  1516. struct hci_rp_le_read_supported_states {
  1517. __u8 status;
  1518. __u8 le_states[8];
  1519. } __packed;
  1520. #define HCI_OP_LE_CONN_PARAM_REQ_REPLY 0x2020
  1521. struct hci_cp_le_conn_param_req_reply {
  1522. __le16 handle;
  1523. __le16 interval_min;
  1524. __le16 interval_max;
  1525. __le16 latency;
  1526. __le16 timeout;
  1527. __le16 min_ce_len;
  1528. __le16 max_ce_len;
  1529. } __packed;
  1530. #define HCI_OP_LE_CONN_PARAM_REQ_NEG_REPLY 0x2021
  1531. struct hci_cp_le_conn_param_req_neg_reply {
  1532. __le16 handle;
  1533. __u8 reason;
  1534. } __packed;
  1535. #define HCI_OP_LE_SET_DATA_LEN 0x2022
  1536. struct hci_cp_le_set_data_len {
  1537. __le16 handle;
  1538. __le16 tx_len;
  1539. __le16 tx_time;
  1540. } __packed;
  1541. struct hci_rp_le_set_data_len {
  1542. __u8 status;
  1543. __le16 handle;
  1544. } __packed;
  1545. #define HCI_OP_LE_READ_DEF_DATA_LEN 0x2023
  1546. struct hci_rp_le_read_def_data_len {
  1547. __u8 status;
  1548. __le16 tx_len;
  1549. __le16 tx_time;
  1550. } __packed;
  1551. #define HCI_OP_LE_WRITE_DEF_DATA_LEN 0x2024
  1552. struct hci_cp_le_write_def_data_len {
  1553. __le16 tx_len;
  1554. __le16 tx_time;
  1555. } __packed;
  1556. #define HCI_OP_LE_ADD_TO_RESOLV_LIST 0x2027
  1557. struct hci_cp_le_add_to_resolv_list {
  1558. __u8 bdaddr_type;
  1559. bdaddr_t bdaddr;
  1560. __u8 peer_irk[16];
  1561. __u8 local_irk[16];
  1562. } __packed;
  1563. #define HCI_OP_LE_DEL_FROM_RESOLV_LIST 0x2028
  1564. struct hci_cp_le_del_from_resolv_list {
  1565. __u8 bdaddr_type;
  1566. bdaddr_t bdaddr;
  1567. } __packed;
  1568. #define HCI_OP_LE_CLEAR_RESOLV_LIST 0x2029
  1569. #define HCI_OP_LE_READ_RESOLV_LIST_SIZE 0x202a
  1570. struct hci_rp_le_read_resolv_list_size {
  1571. __u8 status;
  1572. __u8 size;
  1573. } __packed;
  1574. #define HCI_OP_LE_SET_ADDR_RESOLV_ENABLE 0x202d
  1575. #define HCI_OP_LE_SET_RPA_TIMEOUT 0x202e
  1576. #define HCI_OP_LE_READ_MAX_DATA_LEN 0x202f
  1577. struct hci_rp_le_read_max_data_len {
  1578. __u8 status;
  1579. __le16 tx_len;
  1580. __le16 tx_time;
  1581. __le16 rx_len;
  1582. __le16 rx_time;
  1583. } __packed;
  1584. #define HCI_OP_LE_SET_DEFAULT_PHY 0x2031
  1585. struct hci_cp_le_set_default_phy {
  1586. __u8 all_phys;
  1587. __u8 tx_phys;
  1588. __u8 rx_phys;
  1589. } __packed;
  1590. #define HCI_LE_SET_PHY_1M 0x01
  1591. #define HCI_LE_SET_PHY_2M 0x02
  1592. #define HCI_LE_SET_PHY_CODED 0x04
  1593. #define HCI_OP_LE_SET_EXT_SCAN_PARAMS 0x2041
  1594. struct hci_cp_le_set_ext_scan_params {
  1595. __u8 own_addr_type;
  1596. __u8 filter_policy;
  1597. __u8 scanning_phys;
  1598. __u8 data[];
  1599. } __packed;
  1600. #define LE_SCAN_PHY_1M 0x01
  1601. #define LE_SCAN_PHY_2M 0x02
  1602. #define LE_SCAN_PHY_CODED 0x04
  1603. struct hci_cp_le_scan_phy_params {
  1604. __u8 type;
  1605. __le16 interval;
  1606. __le16 window;
  1607. } __packed;
  1608. #define HCI_OP_LE_SET_EXT_SCAN_ENABLE 0x2042
  1609. struct hci_cp_le_set_ext_scan_enable {
  1610. __u8 enable;
  1611. __u8 filter_dup;
  1612. __le16 duration;
  1613. __le16 period;
  1614. } __packed;
  1615. #define HCI_OP_LE_EXT_CREATE_CONN 0x2043
  1616. struct hci_cp_le_ext_create_conn {
  1617. __u8 filter_policy;
  1618. __u8 own_addr_type;
  1619. __u8 peer_addr_type;
  1620. bdaddr_t peer_addr;
  1621. __u8 phys;
  1622. __u8 data[];
  1623. } __packed;
  1624. struct hci_cp_le_ext_conn_param {
  1625. __le16 scan_interval;
  1626. __le16 scan_window;
  1627. __le16 conn_interval_min;
  1628. __le16 conn_interval_max;
  1629. __le16 conn_latency;
  1630. __le16 supervision_timeout;
  1631. __le16 min_ce_len;
  1632. __le16 max_ce_len;
  1633. } __packed;
  1634. #define HCI_OP_LE_PA_CREATE_SYNC 0x2044
  1635. struct hci_cp_le_pa_create_sync {
  1636. __u8 options;
  1637. __u8 sid;
  1638. __u8 addr_type;
  1639. bdaddr_t addr;
  1640. __le16 skip;
  1641. __le16 sync_timeout;
  1642. __u8 sync_cte_type;
  1643. } __packed;
  1644. #define HCI_OP_LE_PA_CREATE_SYNC_CANCEL 0x2045
  1645. #define HCI_OP_LE_PA_TERM_SYNC 0x2046
  1646. struct hci_cp_le_pa_term_sync {
  1647. __le16 handle;
  1648. } __packed;
  1649. #define HCI_OP_LE_READ_NUM_SUPPORTED_ADV_SETS 0x203b
  1650. struct hci_rp_le_read_num_supported_adv_sets {
  1651. __u8 status;
  1652. __u8 num_of_sets;
  1653. } __packed;
  1654. #define HCI_OP_LE_SET_EXT_ADV_PARAMS 0x2036
  1655. struct hci_cp_le_set_ext_adv_params {
  1656. __u8 handle;
  1657. __le16 evt_properties;
  1658. __u8 min_interval[3];
  1659. __u8 max_interval[3];
  1660. __u8 channel_map;
  1661. __u8 own_addr_type;
  1662. __u8 peer_addr_type;
  1663. bdaddr_t peer_addr;
  1664. __u8 filter_policy;
  1665. __u8 tx_power;
  1666. __u8 primary_phy;
  1667. __u8 secondary_max_skip;
  1668. __u8 secondary_phy;
  1669. __u8 sid;
  1670. __u8 notif_enable;
  1671. } __packed;
  1672. #define HCI_ADV_PHY_1M 0X01
  1673. #define HCI_ADV_PHY_2M 0x02
  1674. #define HCI_ADV_PHY_CODED 0x03
  1675. struct hci_rp_le_set_ext_adv_params {
  1676. __u8 status;
  1677. __u8 tx_power;
  1678. } __packed;
  1679. struct hci_cp_ext_adv_set {
  1680. __u8 handle;
  1681. __le16 duration;
  1682. __u8 max_events;
  1683. } __packed;
  1684. #define HCI_MAX_EXT_AD_LENGTH 251
  1685. #define HCI_OP_LE_SET_EXT_ADV_DATA 0x2037
  1686. struct hci_cp_le_set_ext_adv_data {
  1687. __u8 handle;
  1688. __u8 operation;
  1689. __u8 frag_pref;
  1690. __u8 length;
  1691. __u8 data[] __counted_by(length);
  1692. } __packed;
  1693. #define HCI_OP_LE_SET_EXT_SCAN_RSP_DATA 0x2038
  1694. struct hci_cp_le_set_ext_scan_rsp_data {
  1695. __u8 handle;
  1696. __u8 operation;
  1697. __u8 frag_pref;
  1698. __u8 length;
  1699. __u8 data[] __counted_by(length);
  1700. } __packed;
  1701. #define HCI_OP_LE_SET_EXT_ADV_ENABLE 0x2039
  1702. struct hci_cp_le_set_ext_adv_enable {
  1703. __u8 enable;
  1704. __u8 num_of_sets;
  1705. __u8 data[];
  1706. } __packed;
  1707. #define HCI_OP_LE_SET_PER_ADV_PARAMS 0x203e
  1708. struct hci_cp_le_set_per_adv_params {
  1709. __u8 handle;
  1710. __le16 min_interval;
  1711. __le16 max_interval;
  1712. __le16 periodic_properties;
  1713. } __packed;
  1714. #define HCI_MAX_PER_AD_LENGTH 252
  1715. #define HCI_MAX_PER_AD_TOT_LEN 1650
  1716. #define HCI_OP_LE_SET_PER_ADV_DATA 0x203f
  1717. struct hci_cp_le_set_per_adv_data {
  1718. __u8 handle;
  1719. __u8 operation;
  1720. __u8 length;
  1721. __u8 data[] __counted_by(length);
  1722. } __packed;
  1723. #define HCI_OP_LE_SET_PER_ADV_ENABLE 0x2040
  1724. struct hci_cp_le_set_per_adv_enable {
  1725. __u8 enable;
  1726. __u8 handle;
  1727. } __packed;
  1728. #define LE_SET_ADV_DATA_OP_COMPLETE 0x03
  1729. #define LE_SET_ADV_DATA_NO_FRAG 0x01
  1730. #define HCI_OP_LE_REMOVE_ADV_SET 0x203c
  1731. #define HCI_OP_LE_CLEAR_ADV_SETS 0x203d
  1732. #define HCI_OP_LE_SET_ADV_SET_RAND_ADDR 0x2035
  1733. struct hci_cp_le_set_adv_set_rand_addr {
  1734. __u8 handle;
  1735. bdaddr_t bdaddr;
  1736. } __packed;
  1737. #define HCI_OP_LE_READ_TRANSMIT_POWER 0x204b
  1738. struct hci_rp_le_read_transmit_power {
  1739. __u8 status;
  1740. __s8 min_le_tx_power;
  1741. __s8 max_le_tx_power;
  1742. } __packed;
  1743. #define HCI_NETWORK_PRIVACY 0x00
  1744. #define HCI_DEVICE_PRIVACY 0x01
  1745. #define HCI_OP_LE_SET_PRIVACY_MODE 0x204e
  1746. struct hci_cp_le_set_privacy_mode {
  1747. __u8 bdaddr_type;
  1748. bdaddr_t bdaddr;
  1749. __u8 mode;
  1750. } __packed;
  1751. #define HCI_OP_LE_READ_BUFFER_SIZE_V2 0x2060
  1752. struct hci_rp_le_read_buffer_size_v2 {
  1753. __u8 status;
  1754. __le16 acl_mtu;
  1755. __u8 acl_max_pkt;
  1756. __le16 iso_mtu;
  1757. __u8 iso_max_pkt;
  1758. } __packed;
  1759. #define HCI_OP_LE_READ_ISO_TX_SYNC 0x2061
  1760. struct hci_cp_le_read_iso_tx_sync {
  1761. __le16 handle;
  1762. } __packed;
  1763. struct hci_rp_le_read_iso_tx_sync {
  1764. __u8 status;
  1765. __le16 handle;
  1766. __le16 seq;
  1767. __le32 imestamp;
  1768. __u8 offset[3];
  1769. } __packed;
  1770. #define HCI_OP_LE_SET_CIG_PARAMS 0x2062
  1771. struct hci_cis_params {
  1772. __u8 cis_id;
  1773. __le16 c_sdu;
  1774. __le16 p_sdu;
  1775. __u8 c_phy;
  1776. __u8 p_phy;
  1777. __u8 c_rtn;
  1778. __u8 p_rtn;
  1779. } __packed;
  1780. struct hci_cp_le_set_cig_params {
  1781. __u8 cig_id;
  1782. __u8 c_interval[3];
  1783. __u8 p_interval[3];
  1784. __u8 sca;
  1785. __u8 packing;
  1786. __u8 framing;
  1787. __le16 c_latency;
  1788. __le16 p_latency;
  1789. __u8 num_cis;
  1790. struct hci_cis_params cis[] __counted_by(num_cis);
  1791. } __packed;
  1792. struct hci_rp_le_set_cig_params {
  1793. __u8 status;
  1794. __u8 cig_id;
  1795. __u8 num_handles;
  1796. __le16 handle[];
  1797. } __packed;
  1798. #define HCI_OP_LE_CREATE_CIS 0x2064
  1799. struct hci_cis {
  1800. __le16 cis_handle;
  1801. __le16 acl_handle;
  1802. } __packed;
  1803. struct hci_cp_le_create_cis {
  1804. __u8 num_cis;
  1805. struct hci_cis cis[] __counted_by(num_cis);
  1806. } __packed;
  1807. #define HCI_OP_LE_REMOVE_CIG 0x2065
  1808. struct hci_cp_le_remove_cig {
  1809. __u8 cig_id;
  1810. } __packed;
  1811. #define HCI_OP_LE_ACCEPT_CIS 0x2066
  1812. struct hci_cp_le_accept_cis {
  1813. __le16 handle;
  1814. } __packed;
  1815. #define HCI_OP_LE_REJECT_CIS 0x2067
  1816. struct hci_cp_le_reject_cis {
  1817. __le16 handle;
  1818. __u8 reason;
  1819. } __packed;
  1820. #define HCI_OP_LE_CREATE_BIG 0x2068
  1821. struct hci_bis {
  1822. __u8 sdu_interval[3];
  1823. __le16 sdu;
  1824. __le16 latency;
  1825. __u8 rtn;
  1826. __u8 phy;
  1827. __u8 packing;
  1828. __u8 framing;
  1829. __u8 encryption;
  1830. __u8 bcode[16];
  1831. } __packed;
  1832. struct hci_cp_le_create_big {
  1833. __u8 handle;
  1834. __u8 adv_handle;
  1835. __u8 num_bis;
  1836. struct hci_bis bis;
  1837. } __packed;
  1838. #define HCI_OP_LE_TERM_BIG 0x206a
  1839. struct hci_cp_le_term_big {
  1840. __u8 handle;
  1841. __u8 reason;
  1842. } __packed;
  1843. #define HCI_OP_LE_BIG_CREATE_SYNC 0x206b
  1844. struct hci_cp_le_big_create_sync {
  1845. __u8 handle;
  1846. __le16 sync_handle;
  1847. __u8 encryption;
  1848. __u8 bcode[16];
  1849. __u8 mse;
  1850. __le16 timeout;
  1851. __u8 num_bis;
  1852. __u8 bis[] __counted_by(num_bis);
  1853. } __packed;
  1854. #define HCI_OP_LE_BIG_TERM_SYNC 0x206c
  1855. struct hci_cp_le_big_term_sync {
  1856. __u8 handle;
  1857. } __packed;
  1858. #define HCI_OP_LE_SETUP_ISO_PATH 0x206e
  1859. struct hci_cp_le_setup_iso_path {
  1860. __le16 handle;
  1861. __u8 direction;
  1862. __u8 path;
  1863. __u8 codec;
  1864. __le16 codec_cid;
  1865. __le16 codec_vid;
  1866. __u8 delay[3];
  1867. __u8 codec_cfg_len;
  1868. __u8 codec_cfg[];
  1869. } __packed;
  1870. struct hci_rp_le_setup_iso_path {
  1871. __u8 status;
  1872. __le16 handle;
  1873. } __packed;
  1874. #define HCI_OP_LE_SET_HOST_FEATURE 0x2074
  1875. struct hci_cp_le_set_host_feature {
  1876. __u8 bit_number;
  1877. __u8 bit_value;
  1878. } __packed;
  1879. /* ---- HCI Events ---- */
  1880. struct hci_ev_status {
  1881. __u8 status;
  1882. } __packed;
  1883. #define HCI_EV_INQUIRY_COMPLETE 0x01
  1884. #define HCI_EV_INQUIRY_RESULT 0x02
  1885. struct inquiry_info {
  1886. bdaddr_t bdaddr;
  1887. __u8 pscan_rep_mode;
  1888. __u8 pscan_period_mode;
  1889. __u8 pscan_mode;
  1890. __u8 dev_class[3];
  1891. __le16 clock_offset;
  1892. } __packed;
  1893. struct hci_ev_inquiry_result {
  1894. __u8 num;
  1895. struct inquiry_info info[];
  1896. };
  1897. #define HCI_EV_CONN_COMPLETE 0x03
  1898. struct hci_ev_conn_complete {
  1899. __u8 status;
  1900. __le16 handle;
  1901. bdaddr_t bdaddr;
  1902. __u8 link_type;
  1903. __u8 encr_mode;
  1904. } __packed;
  1905. #define HCI_EV_CONN_REQUEST 0x04
  1906. struct hci_ev_conn_request {
  1907. bdaddr_t bdaddr;
  1908. __u8 dev_class[3];
  1909. __u8 link_type;
  1910. } __packed;
  1911. #define HCI_EV_DISCONN_COMPLETE 0x05
  1912. struct hci_ev_disconn_complete {
  1913. __u8 status;
  1914. __le16 handle;
  1915. __u8 reason;
  1916. } __packed;
  1917. #define HCI_EV_AUTH_COMPLETE 0x06
  1918. struct hci_ev_auth_complete {
  1919. __u8 status;
  1920. __le16 handle;
  1921. } __packed;
  1922. #define HCI_EV_REMOTE_NAME 0x07
  1923. struct hci_ev_remote_name {
  1924. __u8 status;
  1925. bdaddr_t bdaddr;
  1926. __u8 name[HCI_MAX_NAME_LENGTH];
  1927. } __packed;
  1928. #define HCI_EV_ENCRYPT_CHANGE 0x08
  1929. struct hci_ev_encrypt_change {
  1930. __u8 status;
  1931. __le16 handle;
  1932. __u8 encrypt;
  1933. } __packed;
  1934. #define HCI_EV_CHANGE_LINK_KEY_COMPLETE 0x09
  1935. struct hci_ev_change_link_key_complete {
  1936. __u8 status;
  1937. __le16 handle;
  1938. } __packed;
  1939. #define HCI_EV_REMOTE_FEATURES 0x0b
  1940. struct hci_ev_remote_features {
  1941. __u8 status;
  1942. __le16 handle;
  1943. __u8 features[8];
  1944. } __packed;
  1945. #define HCI_EV_REMOTE_VERSION 0x0c
  1946. struct hci_ev_remote_version {
  1947. __u8 status;
  1948. __le16 handle;
  1949. __u8 lmp_ver;
  1950. __le16 manufacturer;
  1951. __le16 lmp_subver;
  1952. } __packed;
  1953. #define HCI_EV_QOS_SETUP_COMPLETE 0x0d
  1954. struct hci_qos {
  1955. __u8 service_type;
  1956. __u32 token_rate;
  1957. __u32 peak_bandwidth;
  1958. __u32 latency;
  1959. __u32 delay_variation;
  1960. } __packed;
  1961. struct hci_ev_qos_setup_complete {
  1962. __u8 status;
  1963. __le16 handle;
  1964. struct hci_qos qos;
  1965. } __packed;
  1966. #define HCI_EV_CMD_COMPLETE 0x0e
  1967. struct hci_ev_cmd_complete {
  1968. __u8 ncmd;
  1969. __le16 opcode;
  1970. } __packed;
  1971. #define HCI_EV_CMD_STATUS 0x0f
  1972. struct hci_ev_cmd_status {
  1973. __u8 status;
  1974. __u8 ncmd;
  1975. __le16 opcode;
  1976. } __packed;
  1977. #define HCI_EV_HARDWARE_ERROR 0x10
  1978. struct hci_ev_hardware_error {
  1979. __u8 code;
  1980. } __packed;
  1981. #define HCI_EV_ROLE_CHANGE 0x12
  1982. struct hci_ev_role_change {
  1983. __u8 status;
  1984. bdaddr_t bdaddr;
  1985. __u8 role;
  1986. } __packed;
  1987. #define HCI_EV_NUM_COMP_PKTS 0x13
  1988. struct hci_comp_pkts_info {
  1989. __le16 handle;
  1990. __le16 count;
  1991. } __packed;
  1992. struct hci_ev_num_comp_pkts {
  1993. __u8 num;
  1994. struct hci_comp_pkts_info handles[];
  1995. } __packed;
  1996. #define HCI_EV_MODE_CHANGE 0x14
  1997. struct hci_ev_mode_change {
  1998. __u8 status;
  1999. __le16 handle;
  2000. __u8 mode;
  2001. __le16 interval;
  2002. } __packed;
  2003. #define HCI_EV_PIN_CODE_REQ 0x16
  2004. struct hci_ev_pin_code_req {
  2005. bdaddr_t bdaddr;
  2006. } __packed;
  2007. #define HCI_EV_LINK_KEY_REQ 0x17
  2008. struct hci_ev_link_key_req {
  2009. bdaddr_t bdaddr;
  2010. } __packed;
  2011. #define HCI_EV_LINK_KEY_NOTIFY 0x18
  2012. struct hci_ev_link_key_notify {
  2013. bdaddr_t bdaddr;
  2014. __u8 link_key[HCI_LINK_KEY_SIZE];
  2015. __u8 key_type;
  2016. } __packed;
  2017. #define HCI_EV_CLOCK_OFFSET 0x1c
  2018. struct hci_ev_clock_offset {
  2019. __u8 status;
  2020. __le16 handle;
  2021. __le16 clock_offset;
  2022. } __packed;
  2023. #define HCI_EV_PKT_TYPE_CHANGE 0x1d
  2024. struct hci_ev_pkt_type_change {
  2025. __u8 status;
  2026. __le16 handle;
  2027. __le16 pkt_type;
  2028. } __packed;
  2029. #define HCI_EV_PSCAN_REP_MODE 0x20
  2030. struct hci_ev_pscan_rep_mode {
  2031. bdaddr_t bdaddr;
  2032. __u8 pscan_rep_mode;
  2033. } __packed;
  2034. #define HCI_EV_INQUIRY_RESULT_WITH_RSSI 0x22
  2035. struct inquiry_info_rssi {
  2036. bdaddr_t bdaddr;
  2037. __u8 pscan_rep_mode;
  2038. __u8 pscan_period_mode;
  2039. __u8 dev_class[3];
  2040. __le16 clock_offset;
  2041. __s8 rssi;
  2042. } __packed;
  2043. struct inquiry_info_rssi_pscan {
  2044. bdaddr_t bdaddr;
  2045. __u8 pscan_rep_mode;
  2046. __u8 pscan_period_mode;
  2047. __u8 pscan_mode;
  2048. __u8 dev_class[3];
  2049. __le16 clock_offset;
  2050. __s8 rssi;
  2051. } __packed;
  2052. struct hci_ev_inquiry_result_rssi {
  2053. __u8 num;
  2054. __u8 data[];
  2055. } __packed;
  2056. #define HCI_EV_REMOTE_EXT_FEATURES 0x23
  2057. struct hci_ev_remote_ext_features {
  2058. __u8 status;
  2059. __le16 handle;
  2060. __u8 page;
  2061. __u8 max_page;
  2062. __u8 features[8];
  2063. } __packed;
  2064. #define HCI_EV_SYNC_CONN_COMPLETE 0x2c
  2065. struct hci_ev_sync_conn_complete {
  2066. __u8 status;
  2067. __le16 handle;
  2068. bdaddr_t bdaddr;
  2069. __u8 link_type;
  2070. __u8 tx_interval;
  2071. __u8 retrans_window;
  2072. __le16 rx_pkt_len;
  2073. __le16 tx_pkt_len;
  2074. __u8 air_mode;
  2075. } __packed;
  2076. #define HCI_EV_SYNC_CONN_CHANGED 0x2d
  2077. struct hci_ev_sync_conn_changed {
  2078. __u8 status;
  2079. __le16 handle;
  2080. __u8 tx_interval;
  2081. __u8 retrans_window;
  2082. __le16 rx_pkt_len;
  2083. __le16 tx_pkt_len;
  2084. } __packed;
  2085. #define HCI_EV_SNIFF_SUBRATE 0x2e
  2086. struct hci_ev_sniff_subrate {
  2087. __u8 status;
  2088. __le16 handle;
  2089. __le16 max_tx_latency;
  2090. __le16 max_rx_latency;
  2091. __le16 max_remote_timeout;
  2092. __le16 max_local_timeout;
  2093. } __packed;
  2094. #define HCI_EV_EXTENDED_INQUIRY_RESULT 0x2f
  2095. struct extended_inquiry_info {
  2096. bdaddr_t bdaddr;
  2097. __u8 pscan_rep_mode;
  2098. __u8 pscan_period_mode;
  2099. __u8 dev_class[3];
  2100. __le16 clock_offset;
  2101. __s8 rssi;
  2102. __u8 data[240];
  2103. } __packed;
  2104. struct hci_ev_ext_inquiry_result {
  2105. __u8 num;
  2106. struct extended_inquiry_info info[];
  2107. } __packed;
  2108. #define HCI_EV_KEY_REFRESH_COMPLETE 0x30
  2109. struct hci_ev_key_refresh_complete {
  2110. __u8 status;
  2111. __le16 handle;
  2112. } __packed;
  2113. #define HCI_EV_IO_CAPA_REQUEST 0x31
  2114. struct hci_ev_io_capa_request {
  2115. bdaddr_t bdaddr;
  2116. } __packed;
  2117. #define HCI_EV_IO_CAPA_REPLY 0x32
  2118. struct hci_ev_io_capa_reply {
  2119. bdaddr_t bdaddr;
  2120. __u8 capability;
  2121. __u8 oob_data;
  2122. __u8 authentication;
  2123. } __packed;
  2124. #define HCI_EV_USER_CONFIRM_REQUEST 0x33
  2125. struct hci_ev_user_confirm_req {
  2126. bdaddr_t bdaddr;
  2127. __le32 passkey;
  2128. } __packed;
  2129. #define HCI_EV_USER_PASSKEY_REQUEST 0x34
  2130. struct hci_ev_user_passkey_req {
  2131. bdaddr_t bdaddr;
  2132. } __packed;
  2133. #define HCI_EV_REMOTE_OOB_DATA_REQUEST 0x35
  2134. struct hci_ev_remote_oob_data_request {
  2135. bdaddr_t bdaddr;
  2136. } __packed;
  2137. #define HCI_EV_SIMPLE_PAIR_COMPLETE 0x36
  2138. struct hci_ev_simple_pair_complete {
  2139. __u8 status;
  2140. bdaddr_t bdaddr;
  2141. } __packed;
  2142. #define HCI_EV_USER_PASSKEY_NOTIFY 0x3b
  2143. struct hci_ev_user_passkey_notify {
  2144. bdaddr_t bdaddr;
  2145. __le32 passkey;
  2146. } __packed;
  2147. #define HCI_KEYPRESS_STARTED 0
  2148. #define HCI_KEYPRESS_ENTERED 1
  2149. #define HCI_KEYPRESS_ERASED 2
  2150. #define HCI_KEYPRESS_CLEARED 3
  2151. #define HCI_KEYPRESS_COMPLETED 4
  2152. #define HCI_EV_KEYPRESS_NOTIFY 0x3c
  2153. struct hci_ev_keypress_notify {
  2154. bdaddr_t bdaddr;
  2155. __u8 type;
  2156. } __packed;
  2157. #define HCI_EV_REMOTE_HOST_FEATURES 0x3d
  2158. struct hci_ev_remote_host_features {
  2159. bdaddr_t bdaddr;
  2160. __u8 features[8];
  2161. } __packed;
  2162. #define HCI_EV_LE_META 0x3e
  2163. struct hci_ev_le_meta {
  2164. __u8 subevent;
  2165. } __packed;
  2166. #define HCI_EV_PHY_LINK_COMPLETE 0x40
  2167. struct hci_ev_phy_link_complete {
  2168. __u8 status;
  2169. __u8 phy_handle;
  2170. } __packed;
  2171. #define HCI_EV_CHANNEL_SELECTED 0x41
  2172. struct hci_ev_channel_selected {
  2173. __u8 phy_handle;
  2174. } __packed;
  2175. #define HCI_EV_DISCONN_PHY_LINK_COMPLETE 0x42
  2176. struct hci_ev_disconn_phy_link_complete {
  2177. __u8 status;
  2178. __u8 phy_handle;
  2179. __u8 reason;
  2180. } __packed;
  2181. #define HCI_EV_LOGICAL_LINK_COMPLETE 0x45
  2182. struct hci_ev_logical_link_complete {
  2183. __u8 status;
  2184. __le16 handle;
  2185. __u8 phy_handle;
  2186. __u8 flow_spec_id;
  2187. } __packed;
  2188. #define HCI_EV_DISCONN_LOGICAL_LINK_COMPLETE 0x46
  2189. struct hci_ev_disconn_logical_link_complete {
  2190. __u8 status;
  2191. __le16 handle;
  2192. __u8 reason;
  2193. } __packed;
  2194. #define HCI_EV_NUM_COMP_BLOCKS 0x48
  2195. struct hci_comp_blocks_info {
  2196. __le16 handle;
  2197. __le16 pkts;
  2198. __le16 blocks;
  2199. } __packed;
  2200. struct hci_ev_num_comp_blocks {
  2201. __le16 num_blocks;
  2202. __u8 num_hndl;
  2203. struct hci_comp_blocks_info handles[];
  2204. } __packed;
  2205. #define HCI_EV_SYNC_TRAIN_COMPLETE 0x4F
  2206. struct hci_ev_sync_train_complete {
  2207. __u8 status;
  2208. } __packed;
  2209. #define HCI_EV_PERIPHERAL_PAGE_RESP_TIMEOUT 0x54
  2210. #define HCI_EV_LE_CONN_COMPLETE 0x01
  2211. struct hci_ev_le_conn_complete {
  2212. __u8 status;
  2213. __le16 handle;
  2214. __u8 role;
  2215. __u8 bdaddr_type;
  2216. bdaddr_t bdaddr;
  2217. __le16 interval;
  2218. __le16 latency;
  2219. __le16 supervision_timeout;
  2220. __u8 clk_accurancy;
  2221. } __packed;
  2222. /* Advertising report event types */
  2223. #define LE_ADV_IND 0x00
  2224. #define LE_ADV_DIRECT_IND 0x01
  2225. #define LE_ADV_SCAN_IND 0x02
  2226. #define LE_ADV_NONCONN_IND 0x03
  2227. #define LE_ADV_SCAN_RSP 0x04
  2228. #define LE_ADV_INVALID 0x05
  2229. /* Legacy event types in extended adv report */
  2230. #define LE_LEGACY_ADV_IND 0x0013
  2231. #define LE_LEGACY_ADV_DIRECT_IND 0x0015
  2232. #define LE_LEGACY_ADV_SCAN_IND 0x0012
  2233. #define LE_LEGACY_NONCONN_IND 0x0010
  2234. #define LE_LEGACY_SCAN_RSP_ADV 0x001b
  2235. #define LE_LEGACY_SCAN_RSP_ADV_SCAN 0x001a
  2236. /* Extended Advertising event types */
  2237. #define LE_EXT_ADV_NON_CONN_IND 0x0000
  2238. #define LE_EXT_ADV_CONN_IND 0x0001
  2239. #define LE_EXT_ADV_SCAN_IND 0x0002
  2240. #define LE_EXT_ADV_DIRECT_IND 0x0004
  2241. #define LE_EXT_ADV_SCAN_RSP 0x0008
  2242. #define LE_EXT_ADV_LEGACY_PDU 0x0010
  2243. #define LE_EXT_ADV_DATA_STATUS_MASK 0x0060
  2244. #define LE_EXT_ADV_EVT_TYPE_MASK 0x007f
  2245. #define ADDR_LE_DEV_PUBLIC 0x00
  2246. #define ADDR_LE_DEV_RANDOM 0x01
  2247. #define ADDR_LE_DEV_PUBLIC_RESOLVED 0x02
  2248. #define ADDR_LE_DEV_RANDOM_RESOLVED 0x03
  2249. #define HCI_EV_LE_ADVERTISING_REPORT 0x02
  2250. struct hci_ev_le_advertising_info {
  2251. __u8 type;
  2252. __u8 bdaddr_type;
  2253. bdaddr_t bdaddr;
  2254. __u8 length;
  2255. __u8 data[];
  2256. } __packed;
  2257. struct hci_ev_le_advertising_report {
  2258. __u8 num;
  2259. struct hci_ev_le_advertising_info info[];
  2260. } __packed;
  2261. #define HCI_EV_LE_CONN_UPDATE_COMPLETE 0x03
  2262. struct hci_ev_le_conn_update_complete {
  2263. __u8 status;
  2264. __le16 handle;
  2265. __le16 interval;
  2266. __le16 latency;
  2267. __le16 supervision_timeout;
  2268. } __packed;
  2269. #define HCI_EV_LE_REMOTE_FEAT_COMPLETE 0x04
  2270. struct hci_ev_le_remote_feat_complete {
  2271. __u8 status;
  2272. __le16 handle;
  2273. __u8 features[8];
  2274. } __packed;
  2275. #define HCI_EV_LE_LTK_REQ 0x05
  2276. struct hci_ev_le_ltk_req {
  2277. __le16 handle;
  2278. __le64 rand;
  2279. __le16 ediv;
  2280. } __packed;
  2281. #define HCI_EV_LE_REMOTE_CONN_PARAM_REQ 0x06
  2282. struct hci_ev_le_remote_conn_param_req {
  2283. __le16 handle;
  2284. __le16 interval_min;
  2285. __le16 interval_max;
  2286. __le16 latency;
  2287. __le16 timeout;
  2288. } __packed;
  2289. #define HCI_EV_LE_DATA_LEN_CHANGE 0x07
  2290. struct hci_ev_le_data_len_change {
  2291. __le16 handle;
  2292. __le16 tx_len;
  2293. __le16 tx_time;
  2294. __le16 rx_len;
  2295. __le16 rx_time;
  2296. } __packed;
  2297. #define HCI_EV_LE_DIRECT_ADV_REPORT 0x0B
  2298. struct hci_ev_le_direct_adv_info {
  2299. __u8 type;
  2300. __u8 bdaddr_type;
  2301. bdaddr_t bdaddr;
  2302. __u8 direct_addr_type;
  2303. bdaddr_t direct_addr;
  2304. __s8 rssi;
  2305. } __packed;
  2306. struct hci_ev_le_direct_adv_report {
  2307. __u8 num;
  2308. struct hci_ev_le_direct_adv_info info[];
  2309. } __packed;
  2310. #define HCI_EV_LE_PHY_UPDATE_COMPLETE 0x0c
  2311. struct hci_ev_le_phy_update_complete {
  2312. __u8 status;
  2313. __le16 handle;
  2314. __u8 tx_phy;
  2315. __u8 rx_phy;
  2316. } __packed;
  2317. #define HCI_EV_LE_EXT_ADV_REPORT 0x0d
  2318. struct hci_ev_le_ext_adv_info {
  2319. __le16 type;
  2320. __u8 bdaddr_type;
  2321. bdaddr_t bdaddr;
  2322. __u8 primary_phy;
  2323. __u8 secondary_phy;
  2324. __u8 sid;
  2325. __u8 tx_power;
  2326. __s8 rssi;
  2327. __le16 interval;
  2328. __u8 direct_addr_type;
  2329. bdaddr_t direct_addr;
  2330. __u8 length;
  2331. __u8 data[];
  2332. } __packed;
  2333. struct hci_ev_le_ext_adv_report {
  2334. __u8 num;
  2335. struct hci_ev_le_ext_adv_info info[];
  2336. } __packed;
  2337. #define HCI_EV_LE_PA_SYNC_ESTABLISHED 0x0e
  2338. struct hci_ev_le_pa_sync_established {
  2339. __u8 status;
  2340. __le16 handle;
  2341. __u8 sid;
  2342. __u8 bdaddr_type;
  2343. bdaddr_t bdaddr;
  2344. __u8 phy;
  2345. __le16 interval;
  2346. __u8 clock_accuracy;
  2347. } __packed;
  2348. #define HCI_EV_LE_ENHANCED_CONN_COMPLETE 0x0a
  2349. struct hci_ev_le_enh_conn_complete {
  2350. __u8 status;
  2351. __le16 handle;
  2352. __u8 role;
  2353. __u8 bdaddr_type;
  2354. bdaddr_t bdaddr;
  2355. bdaddr_t local_rpa;
  2356. bdaddr_t peer_rpa;
  2357. __le16 interval;
  2358. __le16 latency;
  2359. __le16 supervision_timeout;
  2360. __u8 clk_accurancy;
  2361. } __packed;
  2362. #define HCI_EV_LE_PER_ADV_REPORT 0x0f
  2363. struct hci_ev_le_per_adv_report {
  2364. __le16 sync_handle;
  2365. __u8 tx_power;
  2366. __u8 rssi;
  2367. __u8 cte_type;
  2368. __u8 data_status;
  2369. __u8 length;
  2370. __u8 data[];
  2371. } __packed;
  2372. #define LE_PA_DATA_COMPLETE 0x00
  2373. #define LE_PA_DATA_MORE_TO_COME 0x01
  2374. #define LE_PA_DATA_TRUNCATED 0x02
  2375. #define HCI_EV_LE_EXT_ADV_SET_TERM 0x12
  2376. struct hci_evt_le_ext_adv_set_term {
  2377. __u8 status;
  2378. __u8 handle;
  2379. __le16 conn_handle;
  2380. __u8 num_evts;
  2381. } __packed;
  2382. #define HCI_EVT_LE_CIS_ESTABLISHED 0x19
  2383. struct hci_evt_le_cis_established {
  2384. __u8 status;
  2385. __le16 handle;
  2386. __u8 cig_sync_delay[3];
  2387. __u8 cis_sync_delay[3];
  2388. __u8 c_latency[3];
  2389. __u8 p_latency[3];
  2390. __u8 c_phy;
  2391. __u8 p_phy;
  2392. __u8 nse;
  2393. __u8 c_bn;
  2394. __u8 p_bn;
  2395. __u8 c_ft;
  2396. __u8 p_ft;
  2397. __le16 c_mtu;
  2398. __le16 p_mtu;
  2399. __le16 interval;
  2400. } __packed;
  2401. #define HCI_EVT_LE_CIS_REQ 0x1a
  2402. struct hci_evt_le_cis_req {
  2403. __le16 acl_handle;
  2404. __le16 cis_handle;
  2405. __u8 cig_id;
  2406. __u8 cis_id;
  2407. } __packed;
  2408. #define HCI_EVT_LE_CREATE_BIG_COMPLETE 0x1b
  2409. struct hci_evt_le_create_big_complete {
  2410. __u8 status;
  2411. __u8 handle;
  2412. __u8 sync_delay[3];
  2413. __u8 transport_delay[3];
  2414. __u8 phy;
  2415. __u8 nse;
  2416. __u8 bn;
  2417. __u8 pto;
  2418. __u8 irc;
  2419. __le16 max_pdu;
  2420. __le16 interval;
  2421. __u8 num_bis;
  2422. __le16 bis_handle[];
  2423. } __packed;
  2424. #define HCI_EVT_LE_BIG_SYNC_ESTABLISHED 0x1d
  2425. struct hci_evt_le_big_sync_estabilished {
  2426. __u8 status;
  2427. __u8 handle;
  2428. __u8 latency[3];
  2429. __u8 nse;
  2430. __u8 bn;
  2431. __u8 pto;
  2432. __u8 irc;
  2433. __le16 max_pdu;
  2434. __le16 interval;
  2435. __u8 num_bis;
  2436. __le16 bis[];
  2437. } __packed;
  2438. #define HCI_EVT_LE_BIG_INFO_ADV_REPORT 0x22
  2439. struct hci_evt_le_big_info_adv_report {
  2440. __le16 sync_handle;
  2441. __u8 num_bis;
  2442. __u8 nse;
  2443. __le16 iso_interval;
  2444. __u8 bn;
  2445. __u8 pto;
  2446. __u8 irc;
  2447. __le16 max_pdu;
  2448. __u8 sdu_interval[3];
  2449. __le16 max_sdu;
  2450. __u8 phy;
  2451. __u8 framing;
  2452. __u8 encryption;
  2453. } __packed;
  2454. #define HCI_EV_VENDOR 0xff
  2455. /* Internal events generated by Bluetooth stack */
  2456. #define HCI_EV_STACK_INTERNAL 0xfd
  2457. struct hci_ev_stack_internal {
  2458. __u16 type;
  2459. __u8 data[];
  2460. } __packed;
  2461. #define HCI_EV_SI_DEVICE 0x01
  2462. struct hci_ev_si_device {
  2463. __u16 event;
  2464. __u16 dev_id;
  2465. } __packed;
  2466. #define HCI_EV_SI_SECURITY 0x02
  2467. struct hci_ev_si_security {
  2468. __u16 event;
  2469. __u16 proto;
  2470. __u16 subproto;
  2471. __u8 incoming;
  2472. } __packed;
  2473. /* ---- HCI Packet structures ---- */
  2474. #define HCI_COMMAND_HDR_SIZE 3
  2475. #define HCI_EVENT_HDR_SIZE 2
  2476. #define HCI_ACL_HDR_SIZE 4
  2477. #define HCI_SCO_HDR_SIZE 3
  2478. #define HCI_ISO_HDR_SIZE 4
  2479. struct hci_command_hdr {
  2480. __le16 opcode; /* OCF & OGF */
  2481. __u8 plen;
  2482. } __packed;
  2483. struct hci_event_hdr {
  2484. __u8 evt;
  2485. __u8 plen;
  2486. } __packed;
  2487. struct hci_acl_hdr {
  2488. __le16 handle; /* Handle & Flags(PB, BC) */
  2489. __le16 dlen;
  2490. } __packed;
  2491. struct hci_sco_hdr {
  2492. __le16 handle;
  2493. __u8 dlen;
  2494. } __packed;
  2495. struct hci_iso_hdr {
  2496. __le16 handle;
  2497. __le16 dlen;
  2498. __u8 data[];
  2499. } __packed;
  2500. /* ISO data packet status flags */
  2501. #define HCI_ISO_STATUS_VALID 0x00
  2502. #define HCI_ISO_STATUS_INVALID 0x01
  2503. #define HCI_ISO_STATUS_NOP 0x02
  2504. #define HCI_ISO_DATA_HDR_SIZE 4
  2505. struct hci_iso_data_hdr {
  2506. __le16 sn;
  2507. __le16 slen;
  2508. };
  2509. #define HCI_ISO_TS_DATA_HDR_SIZE 8
  2510. struct hci_iso_ts_data_hdr {
  2511. __le32 ts;
  2512. __le16 sn;
  2513. __le16 slen;
  2514. };
  2515. static inline struct hci_event_hdr *hci_event_hdr(const struct sk_buff *skb)
  2516. {
  2517. return (struct hci_event_hdr *) skb->data;
  2518. }
  2519. static inline struct hci_acl_hdr *hci_acl_hdr(const struct sk_buff *skb)
  2520. {
  2521. return (struct hci_acl_hdr *) skb->data;
  2522. }
  2523. static inline struct hci_sco_hdr *hci_sco_hdr(const struct sk_buff *skb)
  2524. {
  2525. return (struct hci_sco_hdr *) skb->data;
  2526. }
  2527. static inline struct hci_iso_hdr *hci_iso_hdr(const struct sk_buff *skb)
  2528. {
  2529. return (struct hci_iso_hdr *)skb->data;
  2530. }
  2531. /* Command opcode pack/unpack */
  2532. #define hci_opcode_pack(ogf, ocf) ((__u16) ((ocf & 0x03ff)|(ogf << 10)))
  2533. #define hci_opcode_ogf(op) (op >> 10)
  2534. #define hci_opcode_ocf(op) (op & 0x03ff)
  2535. /* ACL handle and flags pack/unpack */
  2536. #define hci_handle_pack(h, f) ((__u16) ((h & 0x0fff)|(f << 12)))
  2537. #define hci_handle(h) (h & 0x0fff)
  2538. #define hci_flags(h) (h >> 12)
  2539. /* ISO handle and flags pack/unpack */
  2540. #define hci_iso_flags_pb(f) (f & 0x0003)
  2541. #define hci_iso_flags_ts(f) ((f >> 2) & 0x0001)
  2542. #define hci_iso_flags_pack(pb, ts) ((pb & 0x03) | ((ts & 0x01) << 2))
  2543. /* ISO data length and flags pack/unpack */
  2544. #define hci_iso_data_len_pack(h, f) ((__u16) ((h) | ((f) << 14)))
  2545. #define hci_iso_data_len(h) ((h) & 0x3fff)
  2546. #define hci_iso_data_flags(h) ((h) >> 14)
  2547. /* codec transport types */
  2548. #define HCI_TRANSPORT_SCO_ESCO 0x01
  2549. /* le24 support */
  2550. static inline void hci_cpu_to_le24(__u32 val, __u8 dst[3])
  2551. {
  2552. dst[0] = val & 0xff;
  2553. dst[1] = (val & 0xff00) >> 8;
  2554. dst[2] = (val & 0xff0000) >> 16;
  2555. }
  2556. #endif /* __HCI_H */