a2mp.h 3.1 KB

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