a2mp.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /*
  2. Copyright (c) 2010,2011 Code Aurora Forum. All rights reserved.
  3. Copyright (c) 2011,2012 Intel Corp.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License version 2 and
  6. only version 2 as published by the Free Software Foundation.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. */
  12. #ifndef __A2MP_H
  13. #define __A2MP_H
  14. #include <net/bluetooth/l2cap.h>
  15. #define A2MP_FEAT_EXT 0x8000
  16. enum amp_mgr_state {
  17. READ_LOC_AMP_INFO,
  18. READ_LOC_AMP_ASSOC,
  19. READ_LOC_AMP_ASSOC_FINAL,
  20. WRITE_REMOTE_AMP_ASSOC,
  21. };
  22. struct amp_mgr {
  23. struct list_head list;
  24. struct l2cap_conn *l2cap_conn;
  25. struct l2cap_chan *a2mp_chan;
  26. struct l2cap_chan *bredr_chan;
  27. struct kref kref;
  28. __u8 ident;
  29. __u8 handle;
  30. unsigned long state;
  31. unsigned long flags;
  32. struct list_head amp_ctrls;
  33. struct mutex amp_ctrls_lock;
  34. };
  35. struct a2mp_cmd {
  36. __u8 code;
  37. __u8 ident;
  38. __le16 len;
  39. __u8 data[0];
  40. } __packed;
  41. /* A2MP command codes */
  42. #define A2MP_COMMAND_REJ 0x01
  43. struct a2mp_cmd_rej {
  44. __le16 reason;
  45. __u8 data[0];
  46. } __packed;
  47. #define A2MP_DISCOVER_REQ 0x02
  48. struct a2mp_discov_req {
  49. __le16 mtu;
  50. __le16 ext_feat;
  51. } __packed;
  52. struct a2mp_cl {
  53. __u8 id;
  54. __u8 type;
  55. __u8 status;
  56. } __packed;
  57. #define A2MP_DISCOVER_RSP 0x03
  58. struct a2mp_discov_rsp {
  59. __le16 mtu;
  60. __le16 ext_feat;
  61. struct a2mp_cl cl[0];
  62. } __packed;
  63. #define A2MP_CHANGE_NOTIFY 0x04
  64. #define A2MP_CHANGE_RSP 0x05
  65. #define A2MP_GETINFO_REQ 0x06
  66. struct a2mp_info_req {
  67. __u8 id;
  68. } __packed;
  69. #define A2MP_GETINFO_RSP 0x07
  70. struct a2mp_info_rsp {
  71. __u8 id;
  72. __u8 status;
  73. __le32 total_bw;
  74. __le32 max_bw;
  75. __le32 min_latency;
  76. __le16 pal_cap;
  77. __le16 assoc_size;
  78. } __packed;
  79. #define A2MP_GETAMPASSOC_REQ 0x08
  80. struct a2mp_amp_assoc_req {
  81. __u8 id;
  82. } __packed;
  83. #define A2MP_GETAMPASSOC_RSP 0x09
  84. struct a2mp_amp_assoc_rsp {
  85. __u8 id;
  86. __u8 status;
  87. __u8 amp_assoc[0];
  88. } __packed;
  89. #define A2MP_CREATEPHYSLINK_REQ 0x0A
  90. #define A2MP_DISCONNPHYSLINK_REQ 0x0C
  91. struct a2mp_physlink_req {
  92. __u8 local_id;
  93. __u8 remote_id;
  94. __u8 amp_assoc[0];
  95. } __packed;
  96. #define A2MP_CREATEPHYSLINK_RSP 0x0B
  97. #define A2MP_DISCONNPHYSLINK_RSP 0x0D
  98. struct a2mp_physlink_rsp {
  99. __u8 local_id;
  100. __u8 remote_id;
  101. __u8 status;
  102. } __packed;
  103. /* A2MP response status */
  104. #define A2MP_STATUS_SUCCESS 0x00
  105. #define A2MP_STATUS_INVALID_CTRL_ID 0x01
  106. #define A2MP_STATUS_UNABLE_START_LINK_CREATION 0x02
  107. #define A2MP_STATUS_NO_PHYSICAL_LINK_EXISTS 0x02
  108. #define A2MP_STATUS_COLLISION_OCCURED 0x03
  109. #define A2MP_STATUS_DISCONN_REQ_RECVD 0x04
  110. #define A2MP_STATUS_PHYS_LINK_EXISTS 0x05
  111. #define A2MP_STATUS_SECURITY_VIOLATION 0x06
  112. extern struct list_head amp_mgr_list;
  113. extern struct mutex amp_mgr_list_lock;
  114. struct amp_mgr *amp_mgr_get(struct amp_mgr *mgr);
  115. int amp_mgr_put(struct amp_mgr *mgr);
  116. u8 __next_ident(struct amp_mgr *mgr);
  117. struct l2cap_chan *a2mp_channel_create(struct l2cap_conn *conn,
  118. struct sk_buff *skb);
  119. struct amp_mgr *amp_mgr_lookup_by_state(u8 state);
  120. void a2mp_send(struct amp_mgr *mgr, u8 code, u8 ident, u16 len, void *data);
  121. void a2mp_discover_amp(struct l2cap_chan *chan);
  122. void a2mp_send_getinfo_rsp(struct hci_dev *hdev);
  123. void a2mp_send_getampassoc_rsp(struct hci_dev *hdev, u8 status);
  124. void a2mp_send_create_phy_link_req(struct hci_dev *hdev, u8 status);
  125. void a2mp_send_create_phy_link_rsp(struct hci_dev *hdev, u8 status);
  126. #endif /* __A2MP_H */