a2mp.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. enum amp_mgr_state {
  16. READ_LOC_AMP_INFO,
  17. READ_LOC_AMP_ASSOC,
  18. READ_LOC_AMP_ASSOC_FINAL,
  19. WRITE_REMOTE_AMP_ASSOC,
  20. };
  21. struct amp_mgr {
  22. struct list_head list;
  23. struct l2cap_conn *l2cap_conn;
  24. struct l2cap_chan *a2mp_chan;
  25. struct l2cap_chan *bredr_chan;
  26. struct kref kref;
  27. __u8 ident;
  28. __u8 handle;
  29. unsigned long state;
  30. unsigned long flags;
  31. struct list_head amp_ctrls;
  32. struct mutex amp_ctrls_lock;
  33. };
  34. struct a2mp_cmd {
  35. __u8 code;
  36. __u8 ident;
  37. __le16 len;
  38. __u8 data[0];
  39. } __packed;
  40. /* A2MP command codes */
  41. #define A2MP_COMMAND_REJ 0x01
  42. struct a2mp_cmd_rej {
  43. __le16 reason;
  44. __u8 data[0];
  45. } __packed;
  46. #define A2MP_DISCOVER_REQ 0x02
  47. struct a2mp_discov_req {
  48. __le16 mtu;
  49. __le16 ext_feat;
  50. } __packed;
  51. struct a2mp_cl {
  52. __u8 id;
  53. __u8 type;
  54. __u8 status;
  55. } __packed;
  56. #define A2MP_DISCOVER_RSP 0x03
  57. struct a2mp_discov_rsp {
  58. __le16 mtu;
  59. __le16 ext_feat;
  60. struct a2mp_cl cl[0];
  61. } __packed;
  62. #define A2MP_CHANGE_NOTIFY 0x04
  63. #define A2MP_CHANGE_RSP 0x05
  64. #define A2MP_GETINFO_REQ 0x06
  65. struct a2mp_info_req {
  66. __u8 id;
  67. } __packed;
  68. #define A2MP_GETINFO_RSP 0x07
  69. struct a2mp_info_rsp {
  70. __u8 id;
  71. __u8 status;
  72. __le32 total_bw;
  73. __le32 max_bw;
  74. __le32 min_latency;
  75. __le16 pal_cap;
  76. __le16 assoc_size;
  77. } __packed;
  78. #define A2MP_GETAMPASSOC_REQ 0x08
  79. struct a2mp_amp_assoc_req {
  80. __u8 id;
  81. } __packed;
  82. #define A2MP_GETAMPASSOC_RSP 0x09
  83. struct a2mp_amp_assoc_rsp {
  84. __u8 id;
  85. __u8 status;
  86. __u8 amp_assoc[0];
  87. } __packed;
  88. #define A2MP_CREATEPHYSLINK_REQ 0x0A
  89. #define A2MP_DISCONNPHYSLINK_REQ 0x0C
  90. struct a2mp_physlink_req {
  91. __u8 local_id;
  92. __u8 remote_id;
  93. __u8 amp_assoc[0];
  94. } __packed;
  95. #define A2MP_CREATEPHYSLINK_RSP 0x0B
  96. #define A2MP_DISCONNPHYSLINK_RSP 0x0D
  97. struct a2mp_physlink_rsp {
  98. __u8 local_id;
  99. __u8 remote_id;
  100. __u8 status;
  101. } __packed;
  102. /* A2MP response status */
  103. #define A2MP_STATUS_SUCCESS 0x00
  104. #define A2MP_STATUS_INVALID_CTRL_ID 0x01
  105. #define A2MP_STATUS_UNABLE_START_LINK_CREATION 0x02
  106. #define A2MP_STATUS_NO_PHYSICAL_LINK_EXISTS 0x02
  107. #define A2MP_STATUS_COLLISION_OCCURED 0x03
  108. #define A2MP_STATUS_DISCONN_REQ_RECVD 0x04
  109. #define A2MP_STATUS_PHYS_LINK_EXISTS 0x05
  110. #define A2MP_STATUS_SECURITY_VIOLATION 0x06
  111. struct amp_mgr *amp_mgr_get(struct amp_mgr *mgr);
  112. #if IS_ENABLED(CONFIG_BT_HS)
  113. int amp_mgr_put(struct amp_mgr *mgr);
  114. struct l2cap_chan *a2mp_channel_create(struct l2cap_conn *conn,
  115. struct sk_buff *skb);
  116. void a2mp_discover_amp(struct l2cap_chan *chan);
  117. #else
  118. static inline int amp_mgr_put(struct amp_mgr *mgr)
  119. {
  120. return 0;
  121. }
  122. static inline struct l2cap_chan *a2mp_channel_create(struct l2cap_conn *conn,
  123. struct sk_buff *skb)
  124. {
  125. return NULL;
  126. }
  127. static inline void a2mp_discover_amp(struct l2cap_chan *chan)
  128. {
  129. }
  130. #endif
  131. void a2mp_send_getinfo_rsp(struct hci_dev *hdev);
  132. void a2mp_send_getampassoc_rsp(struct hci_dev *hdev, u8 status);
  133. void a2mp_send_create_phy_link_req(struct hci_dev *hdev, u8 status);
  134. void a2mp_send_create_phy_link_rsp(struct hci_dev *hdev, u8 status);
  135. #endif /* __A2MP_H */