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