Linux bluetooth development
 help / color / mirror / Atom feed
From: Andrei Emeltchenko <andrei.emeltchenko.news@gmail.com>
To: Mat Martineau <mathewm@codeaurora.org>
Cc: linux-bluetooth@vger.kernel.org, gustavo@padovan.org,
	sunnyk@codeaurora.org
Subject: Re: [RFCv1 03/20] Bluetooth: Add L2CAP create channel request handling
Date: Mon, 1 Oct 2012 13:16:06 +0300	[thread overview]
Message-ID: <20121001101605.GO10053@aemeltch-MOBL1> (raw)
In-Reply-To: <1347387691-5285-4-git-send-email-mathewm@codeaurora.org>

Hi Mat,

On Tue, Sep 11, 2012 at 11:21:14AM -0700, Mat Martineau wrote:
> The L2CAP create channel request is very similar to an L2CAP connect
> request, but it has an additional parameter for the controller ID.  If
> the controller id is 0, the channel is set up on the BR/EDR controller
> (just like a connect request).  Using a valid high speed controller ID
> will cause the channel to be initially created on that high speed
> controller.  While the L2CAP data will be initially routed over the
> AMP controller, the L2CAP fixed signaling channel only uses BR/EDR.
> 
> When a create channel request is received for a high speed controller,
> a pending response is always sent first.  After the high speed
> physical and logical links are complete a success response will be
> sent.
> 
> Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
> ---
>  net/bluetooth/l2cap_core.c | 70 +++++++++++++++++++++++++++++++++++-----------
>  1 file changed, 54 insertions(+), 16 deletions(-)
> 
> diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
> index 166382c..17e02d9 100644
> --- a/net/bluetooth/l2cap_core.c
> +++ b/net/bluetooth/l2cap_core.c
> @@ -3362,8 +3362,9 @@ static inline int l2cap_command_rej(struct l2cap_conn *conn, struct l2cap_cmd_hd
>  	return 0;
>  }
>  
> -static void __l2cap_connect(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd,
> -			    u8 *data, u8 rsp_code, u8 amp_id)
> +static struct l2cap_chan *__l2cap_connect(struct l2cap_conn *conn,
> +					  struct l2cap_cmd_hdr *cmd,
> +					  u8 *data, u8 rsp_code, u8 amp_id)
>  {
>  	struct l2cap_conn_req *req = (struct l2cap_conn_req *) data;
>  	struct l2cap_conn_rsp rsp;
> @@ -3390,7 +3391,7 @@ static void __l2cap_connect(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd,
>  
>  	/* Check if the ACL is secure enough (if not SDP) */
>  	if (psm != __constant_cpu_to_le16(L2CAP_PSM_SDP) &&
> -				!hci_conn_check_link_mode(conn->hcon)) {
> +	    !hci_conn_check_link_mode(conn->hcon)) {
>  		conn->disc_reason = HCI_ERROR_AUTH_FAILURE;
>  		result = L2CAP_CR_SEC_BLOCK;
>  		goto response;
> @@ -3414,6 +3415,7 @@ static void __l2cap_connect(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd,
>  	bacpy(&bt_sk(sk)->dst, conn->dst);
>  	chan->psm  = psm;
>  	chan->dcid = scid;
> +	chan->local_amp_id = amp_id;
>  
>  	bt_accept_enqueue(parent, sk);
>  
> @@ -3433,8 +3435,16 @@ static void __l2cap_connect(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd,
>  				status = L2CAP_CS_AUTHOR_PEND;
>  				parent->sk_data_ready(parent, 0);
>  			} else {
> -				__l2cap_state_change(chan, BT_CONFIG);
> -				result = L2CAP_CR_SUCCESS;
> +				/* Force pending result for AMP controllers.
> +				 * The connection will succeed after the
> +				 * physical link is up. */
> +				if (amp_id) {
> +					__l2cap_state_change(chan, BT_CONNECT2);
> +					result = L2CAP_CR_PEND;
> +				} else {
> +					__l2cap_state_change(chan, BT_CONFIG);
> +					result = L2CAP_CR_SUCCESS;
> +				}
>  				status = L2CAP_CS_NO_INFO;
>  			}
>  		} else {
> @@ -3480,6 +3490,8 @@ sendresp:
>  					l2cap_build_conf_req(chan, buf), buf);
>  		chan->num_conf_req++;
>  	}
> +
> +	return chan;
>  }
>  
>  static int l2cap_connect_req(struct l2cap_conn *conn,
> @@ -3970,12 +3982,12 @@ static inline int l2cap_information_rsp(struct l2cap_conn *conn, struct l2cap_cm
>  	return 0;
>  }
>  
> -static inline int l2cap_create_channel_req(struct l2cap_conn *conn,
> -					struct l2cap_cmd_hdr *cmd, u16 cmd_len,
> -					void *data)
> +static int l2cap_create_channel_req(struct l2cap_conn *conn,
> +				    struct l2cap_cmd_hdr *cmd, u16 cmd_len,
> +				    void *data)
>  {
>  	struct l2cap_create_chan_req *req = data;
> -	struct l2cap_create_chan_rsp rsp;
> +	struct l2cap_chan *chan;
>  	u16 psm, scid;
>  
>  	if (cmd_len != sizeof(*req))
> @@ -3989,14 +4001,40 @@ static inline int l2cap_create_channel_req(struct l2cap_conn *conn,
>  
>  	BT_DBG("psm 0x%2.2x, scid 0x%4.4x, amp_id %d", psm, scid, req->amp_id);
>  
> -	/* Placeholder: Always reject */
> -	rsp.dcid = 0;
> -	rsp.scid = cpu_to_le16(scid);
> -	rsp.result = __constant_cpu_to_le16(L2CAP_CR_NO_MEM);
> -	rsp.status = __constant_cpu_to_le16(L2CAP_CS_NO_INFO);
> +	if (req->amp_id) {
> +		struct hci_dev *hdev;
>  
> -	l2cap_send_cmd(conn, cmd->ident, L2CAP_CREATE_CHAN_RSP,
> -		       sizeof(rsp), &rsp);
> +		/* Validate AMP controller id */
> +		hdev = hci_dev_get(req->amp_id);
> +		if (!hdev || hdev->dev_type != HCI_AMP ||
> +		    !test_bit(HCI_UP, &hdev->flags)) {
> +			struct l2cap_create_chan_rsp rsp;
> +
> +			rsp.dcid = 0;
> +			rsp.scid = cpu_to_le16(scid);
> +			rsp.result = L2CAP_CR_BAD_AMP;
> +			rsp.status = L2CAP_CS_NO_INFO;
> +
> +			l2cap_send_cmd(conn, cmd->ident, L2CAP_CREATE_CHAN_RSP,
> +				       sizeof(rsp), &rsp);
> +
> +			if (hdev)
> +				hci_dev_put(hdev);
> +
> +			return 0;
> +		}
> +
> +		hci_dev_put(hdev);
> +	}
> +
> +	chan = __l2cap_connect(conn, cmd, data, L2CAP_CREATE_CHAN_RSP,
> +			       req->amp_id);
> +
> +	/* Placeholder - uncomment when amp functions are available
> +	if (chan && req->amp_id &&
> +	    (conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_DONE))
> +		amp_accept_physical(conn, req->amp_id, chan);
> +	*/

I believe this comment shall be deleted, we accept physical link long time
ago before this sequence.

Best regards 
Andrei Emeltchenko 


  parent reply	other threads:[~2012-10-01 10:16 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-11 18:21 [RFCv1 00/20] L2CAP signaling for AMP channel create/move Mat Martineau
2012-09-11 18:21 ` [RFCv1 01/20] Bluetooth: Add new l2cap_chan struct members for high speed channels Mat Martineau
2012-09-20 10:39   ` Andrei Emeltchenko
2012-10-01  8:29   ` Andrei Emeltchenko
2012-09-11 18:21 ` [RFCv1 02/20] Bluetooth: Factor out common L2CAP connection code Mat Martineau
2012-10-01  8:30   ` Andrei Emeltchenko
2012-09-11 18:21 ` [RFCv1 03/20] Bluetooth: Add L2CAP create channel request handling Mat Martineau
2012-09-25 11:39   ` Andrei Emeltchenko
2012-09-25 18:57     ` Mat Martineau
2012-10-01 10:16   ` Andrei Emeltchenko [this message]
2012-09-11 18:21 ` [RFCv1 04/20] Bluetooth: Process create response and connect response identically Mat Martineau
2012-10-01  8:37   ` Andrei Emeltchenko
2012-09-11 18:21 ` [RFCv1 05/20] Bluetooth: Lookup channel structure based on DCID Mat Martineau
2012-09-11 18:21 ` [RFCv1 06/20] Bluetooth: Channel move request handling Mat Martineau
2012-09-11 18:21 ` [RFCv1 07/20] Bluetooth: Add new ERTM receive states for channel move Mat Martineau
2012-09-11 18:21 ` [RFCv1 08/20] Bluetooth: Add move channel confirm handling Mat Martineau
2012-09-11 18:21 ` [RFCv1 09/20] Bluetooth: Add state to hci_chan Mat Martineau
2012-09-11 18:21 ` [RFCv1 10/20] Bluetooth: Move channel response Mat Martineau
2012-09-11 18:21 ` [RFCv1 11/20] Bluetooth: Add logical link confirm Mat Martineau
2012-09-11 18:21 ` [RFCv1 12/20] Bluetooth: Add move confirm response handling Mat Martineau
2012-09-11 18:21 ` [RFCv1 13/20] Bluetooth: Handle physical link completion Mat Martineau
2012-09-11 18:21 ` [RFCv1 14/20] Bluetooth: Flag ACL frames as complete for AMP controllers Mat Martineau
2012-09-11 18:21 ` [RFCv1 15/20] Bluetooth: Do not send data during channel move Mat Martineau
2012-09-11 18:21 ` [RFCv1 16/20] Bluetooth: Configure appropriate timeouts for AMP controllers Mat Martineau
2012-09-11 18:21 ` [RFCv1 17/20] Bluetooth: Ignore BR/EDR packet size constraints when fragmenting for AMP Mat Martineau
2012-10-01  8:46   ` Andrei Emeltchenko
2012-09-11 18:21 ` [RFCv1 18/20] Bluetooth: Send create channel request instead of connect " Mat Martineau
2012-09-11 18:21 ` [RFCv1 19/20] Bluetooth: Do not retransmit data during a channel move Mat Martineau
2012-09-11 18:21 ` [RFCv1 20/20] Bluetooth: Start channel move when socket option is changed Mat Martineau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121001101605.GO10053@aemeltch-MOBL1 \
    --to=andrei.emeltchenko.news@gmail.com \
    --cc=gustavo@padovan.org \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=mathewm@codeaurora.org \
    --cc=sunnyk@codeaurora.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox