From: Andrei Emeltchenko <Andrei.Emeltchenko.news@gmail.com>
To: Mat Martineau <mathewm@codeaurora.org>
Cc: linux-bluetooth@vger.kernel.org, gustavo@padovan.org,
pkrystad@codeaurora.org
Subject: Re: [RFCv0 03/21] Bluetooth: Add L2CAP create channel request handling.
Date: Thu, 26 Jul 2012 16:13:53 +0300 [thread overview]
Message-ID: <20120726131351.GA2686@aemeltch-MOBL1> (raw)
In-Reply-To: <1343260274-11953-4-git-send-email-mathewm@codeaurora.org>
Hi Mat,
On Wed, Jul 25, 2012 at 04:50:55PM -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 | 69 +++++++++++++++++++++++++++++++++++-----------
> 1 file changed, 53 insertions(+), 16 deletions(-)
>
> diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
> index 24000ad..131d0da 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 chan_id)
Do you think chan_id is better then amp_id? At least for channel connect amp_id
looks better.
> {
> 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)) {
This change (and maybe some others may be merged with previous patch) ?
> 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->chan_id = chan_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 (chan_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,39 @@ 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 || !test_bit(HCI_UP, &hdev->flags)) {
Should we also check dev_type here? This might be second BREDR controller.
> + 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, sk);
I hope "sk" is a typo, we shall use "chan" here.
Best regards
Andrei Emeltchenko
next prev parent reply other threads:[~2012-07-26 13:13 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-25 23:50 [RFCv0 00/21] L2CAP signaling for AMP channel create/move Mat Martineau
2012-07-25 23:50 ` [RFCv0 01/21] Bluetooth: Add new l2cap_chan struct members for high speed channels Mat Martineau
2012-07-25 23:50 ` [RFCv0 02/21] Bluetooth: Factor out common L2CAP connection code Mat Martineau
2012-07-25 23:50 ` [RFCv0 03/21] Bluetooth: Add L2CAP create channel request handling Mat Martineau
2012-07-26 13:13 ` Andrei Emeltchenko [this message]
2012-07-26 15:04 ` Mat Martineau
2012-07-26 19:43 ` Andrei Emeltchenko
2012-07-25 23:50 ` [RFCv0 04/21] Bluetooth: Process create response and connect response identically Mat Martineau
2012-08-14 10:12 ` Andrei Emeltchenko
2012-08-14 17:25 ` Mat Martineau
2012-07-25 23:50 ` [RFCv0 05/21] Bluetooth: Lookup channel id for channel move Mat Martineau
2012-07-26 13:30 ` Andrei Emeltchenko
2012-07-26 15:07 ` Mat Martineau
2012-07-25 23:50 ` [RFCv0 06/21] Bluetooth: Channel move request handling Mat Martineau
2012-07-26 13:59 ` Andrei Emeltchenko
2012-07-27 16:54 ` Mat Martineau
2012-08-06 8:44 ` Andrei Emeltchenko
2012-08-06 16:33 ` Mat Martineau
2012-08-07 8:31 ` Andrei Emeltchenko
2012-07-25 23:50 ` [RFCv0 07/21] Bluetooth: Add new ERTM receive states for channel move Mat Martineau
2012-07-25 23:51 ` [RFCv0 08/21] Bluetooth: Add move channel confirm handling Mat Martineau
2012-07-26 14:28 ` Andrei Emeltchenko
2012-07-26 15:16 ` Mat Martineau
2012-07-25 23:51 ` [RFCv0 09/21] Bluetooth: Move channel response Mat Martineau
2012-07-25 23:51 ` [RFCv0 10/21] Bluetooth: Add logical link confirm Mat Martineau
2012-07-26 14:41 ` Andrei Emeltchenko
2012-07-26 15:24 ` Mat Martineau
2012-07-25 23:51 ` [RFCv0 11/21] Bluetooth: Add move confirm response handling Mat Martineau
2012-07-26 14:45 ` Andrei Emeltchenko
2012-07-26 15:33 ` Mat Martineau
2012-07-25 23:51 ` [RFCv0 12/21] Bluetooth: Add state to hci_chan Mat Martineau
2012-07-26 19:54 ` Andrei Emeltchenko
2012-07-25 23:51 ` [RFCv0 13/21] Bluetooth: Indentation fixes Mat Martineau
2012-07-25 23:51 ` [RFCv0 14/21] Bluetooth: Handle physical link completion Mat Martineau
2012-08-15 13:51 ` Andrei Emeltchenko
2012-08-15 16:56 ` Mat Martineau
2012-08-16 7:23 ` Andrei Emeltchenko
2012-07-25 23:51 ` [RFCv0 15/21] Bluetooth: Enable data sends on AMP controller Mat Martineau
2012-07-25 23:51 ` [RFCv0 16/21] Bluetooth: Do not send data during channel move Mat Martineau
2012-07-25 23:51 ` [RFCv0 17/21] Bluetooth: Configure appropriate timeouts for AMP controllers Mat Martineau
2012-07-25 23:51 ` [RFCv0 18/21] Bluetooth: Ignore BR/EDR packet size constraints when fragmenting for AMP Mat Martineau
2012-07-25 23:51 ` [RFCv0 19/21] Bluetooth: Tie AMP link setup to connect/disconnect Mat Martineau
2012-07-25 23:51 ` [RFCv0 20/21] Bluetooth: Do not process ERTM reject during move Mat Martineau
2012-07-25 23:51 ` [RFCv0 21/21] 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=20120726131351.GA2686@aemeltch-MOBL1 \
--to=andrei.emeltchenko.news@gmail.com \
--cc=gustavo@padovan.org \
--cc=linux-bluetooth@vger.kernel.org \
--cc=mathewm@codeaurora.org \
--cc=pkrystad@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;
as well as URLs for NNTP newsgroup(s).