a2mp.h 3.2 KB

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