]> git.openfabrics.org - ~shefty/rdma-dev.git/log
~shefty/rdma-dev.git
12 years agoBluetooth: Fix not setting HCI_RESET flag for AMP
Andrei Emeltchenko [Mon, 11 Jun 2012 08:13:10 +0000 (11:13 +0300)]
Bluetooth: Fix not setting HCI_RESET flag for AMP

Move reset function to common initialization section fixing
not setting HCI_RESET flag for amp_init.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: Correct debug print specifier for u16 objects
Andrei Emeltchenko [Mon, 11 Jun 2012 08:13:09 +0000 (11:13 +0300)]
Bluetooth: Correct debug print specifier for u16 objects

Some functions print u16 objects as "0xc03" others as "0x0c03". Patch
ensures that opcodes printed are the in the same format and consistent
with bluetooth code.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: Add opcode to error message
Andrei Emeltchenko [Mon, 11 Jun 2012 08:13:08 +0000 (11:13 +0300)]
Bluetooth: Add opcode to error message

Sometimes HCI command sending timeouts and gives error message without
specifying which command causes error. Patch makes sure that opcode
is printed to help debugging.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: Update HCI timeouts constants to use msecs_to_jiffies
Andrei Emeltchenko [Mon, 11 Jun 2012 08:13:07 +0000 (11:13 +0300)]
Bluetooth: Update HCI timeouts constants to use msecs_to_jiffies

The HCI constants are always used in form of jiffies. So just
include the conversion from msecs in the define itself. This has the
advantage of making the code where the timeout is used more readable
and avoiding unnecessary conversions.

The patch is similar to commit ba13ccd9 doing the same job for L2CAP

Reported-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: Use standard HCI cmd timeout for RESET
Andrei Emeltchenko [Mon, 11 Jun 2012 08:13:06 +0000 (11:13 +0300)]
Bluetooth: Use standard HCI cmd timeout for RESET

Remove magic and use standard HCI cmd timeout

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoMerge branch 'for-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetoot...
Gustavo Padovan [Tue, 12 Jun 2012 01:36:42 +0000 (22:36 -0300)]
Merge branch 'for-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth

Conflicts:
net/bluetooth/hci_event.c

12 years agoBluetooth: Fix style in hidp code
Gustavo Padovan [Sat, 9 Jun 2012 22:22:42 +0000 (19:22 -0300)]
Bluetooth: Fix style in hidp code

Follow the net rules.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: Add support for encryption key refresh
Johan Hedberg [Fri, 8 Jun 2012 15:31:13 +0000 (23:31 +0800)]
Bluetooth: Add support for encryption key refresh

With LE/SMP the completion of a security level elavation from medium to
high is indicated by a HCI Encryption Key Refresh Complete event. The
necessary behavior upon receiving this event is a mix of what's done for
auth_complete and encryption_change, which is also where most of the
event handling code has been copied from.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: Fix SMP security elevation from medium to high
Johan Hedberg [Thu, 7 Jun 2012 06:58:37 +0000 (14:58 +0800)]
Bluetooth: Fix SMP security elevation from medium to high

If we have an unauthenticated key it is not sufficient to acheive high
security. Therefore, when deciding whether to encrypt the link or
request pairing, it is essential to in addition to checking the
existence of a key to also check whether it is authenticated or not.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: Fix deadlock and crash when SMP pairing times out
Johan Hedberg [Wed, 6 Jun 2012 10:44:11 +0000 (18:44 +0800)]
Bluetooth: Fix deadlock and crash when SMP pairing times out

The l2cap_conn_del function tries to cancel_sync the security timer, but
when it's called from the timeout function itself a deadlock occurs.
Subsequently the "hcon->l2cap_data = NULL" that's supposed to protect
multiple calls to l2cap_conn_del never gets cleared and when the
connection finally drops we double free's etc which will crash the
kernel.

This patch fixes the issue by using the HCI_CONN_LE_SMP_PEND for
protecting against this. The same flag is also used for the same purpose
in other places in the SMP code.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: Fix LE pairing completion on connection failure
Vishal Agarwal [Thu, 7 Jun 2012 14:57:35 +0000 (20:27 +0530)]
Bluetooth: Fix LE pairing completion on connection failure

For BR/EDR pairing is assumed to be finished when connection is
done. For LE if connection is successful it did not necessarily
mean that pairing is also done but if the connection is unsuccessful
it should be assumed that pairing procedure is also finished.
This patch registers a new function with connect_cfm_cb callback for
LE link which sends the pairing complete signal to user space if
connection is unsuccessful.

Signed-off-by: Vishal Agarwal <vishal.agarwal@stericsson.com>
Acked-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: Fix SMP pairing method selection
Johan Hedberg [Wed, 6 Jun 2012 10:54:15 +0000 (18:54 +0800)]
Bluetooth: Fix SMP pairing method selection

The tk_request function takes the local IO capability as the second last
parameter and the remote IO capability as the last parameter. They were
previously swapped: when we receive a pairing response
req->io_capability contains the local one and rsp->io_capability the
remote one.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: Remove magic disconnect reason
Andrei Emeltchenko [Fri, 1 Jun 2012 13:18:25 +0000 (16:18 +0300)]
Bluetooth: Remove magic disconnect reason

The macro gives a better idea of the what the error really is.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: Fix checking the wrong flag when accepting a socket
Vinicius Costa Gomes [Fri, 1 Jun 2012 01:53:39 +0000 (22:53 -0300)]
Bluetooth: Fix checking the wrong flag when accepting a socket

Most probably a typo, the check should have been for BT_SK_DEFER_SETUP
instead of BT_DEFER_SETUP (which right now only represents a socket
option).

Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@openbossa.org>
Acked-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: Filter duplicated reports in LE scan
Andre Guedes [Thu, 31 May 2012 23:01:41 +0000 (20:01 -0300)]
Bluetooth: Filter duplicated reports in LE scan

This patch enables filtering duplicated advertising reports during
LE scan.

Some LE devices advertise using very small intervals generating lots
of equal advertising report events to the host. Each event generates
a mgmt_device_found event which is copied to userspace.

Enabling this feature, duplicated advertising reports are filtered
at controller's link layer. This way, the controller doesn't wake up
the host to report duplicated advertising reports and, consequently,
less data is copied to userspace.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: Create empty l2cap ops function
Gustavo Padovan [Tue, 29 May 2012 16:19:26 +0000 (13:19 -0300)]
Bluetooth: Create empty l2cap ops function

A2MP doesn't use part of the L2CAP chan ops API so we just create general
empty function instead of the A2MP specific one.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
12 years agoBluetooth: Rename L2CAP_LE_DEFAULT_MTU
Andre Guedes [Thu, 31 May 2012 20:01:35 +0000 (17:01 -0300)]
Bluetooth: Rename L2CAP_LE_DEFAULT_MTU

This patch renames L2CAP_LE_DEFAULT_MTU macro to L2CAP_LE_MIN_MTU
since it represents the minimum MTU value, not the default MTU
value for LE.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: Check MTU value in l2cap_sock_setsockopt_old
Andre Guedes [Thu, 31 May 2012 20:01:34 +0000 (17:01 -0300)]
Bluetooth: Check MTU value in l2cap_sock_setsockopt_old

If user tries to set an invalid MTU value, l2cap_sock_setsockopt_old
should return -EINVAL.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: Change default MTU for L2CAP ATT channel
Andre Guedes [Thu, 31 May 2012 20:01:33 +0000 (17:01 -0300)]
Bluetooth: Change default MTU for L2CAP ATT channel

This patch changes the default MTU value for L2CAP ATT fixed channel
to L2CAP_DEFAULT_MTU (672 octets).

Differently from others L2CAP channels, in L2CAP ATT fixed channel
there is no MTU negotiation. The MTU value for that channel is up to
the L2CAP implementation. The only restriction in L2CAP spec is the
MTU value must not be less than 23 octets.

At ATT protocol level (on top of L2CAP), we have the ATT_MTU which
defines the maximum size of any ATT message sent between client and
server. GATT profile defines ATT_MTU default value to 23 octets. If
a GATT based profile wants to use ATT_MTU greater than 23 octets
(e.g. HID over GATT profile), it should negotiate a new value by
executing the GATT Exchange MTU sub-procedure.

Thus, in order to support any value of ATT_MTU negotiated at ATT
protocol level, our L2CAP implementation should have L2CAP ATT
fixed channel MTU equal or greater than ATT_MAX_MTU (512 octets).

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: Fix not removing hci_conn for failed LE connection
Andrzej Kaczmarek [Wed, 30 May 2012 13:39:23 +0000 (15:39 +0200)]
Bluetooth: Fix not removing hci_conn for failed LE connection

This patch changes way LE Connection Complete event with error status are
handled. BDADDR returned in such event packet do not need to be valid and
should not be used to search for existing hci_conn. Instead, any hci_conn
with BT_CONNECT state should be matched since there can be only one
pending LE outgoing connection at any time.

If not handled properly, appriopriate hci_conn will not be removed and
subsequent connection to given peer will try to reuse it without making
actual connection attempt.

2012-05-07 11:21:39.133378 < HCI Command: LE Create Connection (0x08|0x000d) plen 25
    bdaddr 00:22:D0:10:13:EE type 1
2012-05-07 11:21:39.138774 > HCI Event: Command Status (0x0f) plen 4
    LE Create Connection (0x08|0x000d) status 0x00 ncmd 1
2012-05-07 11:21:44.752854 < HCI Command: LE Create Connection Cancel (0x08|0x000e) plen 0
2012-05-07 11:21:44.759475 > HCI Event: Command Complete (0x0e) plen 4
    LE Create Connection Cancel (0x08|0x000e) ncmd 1
2012-05-07 11:21:44.764479 > HCI Event: LE Meta Event (0x3e) plen 19
    LE Connection Complete
      status 0x02 handle 0, role master
      bdaddr 00:00:00:00:00:00 (Public)

[14898.739425] [6603] hci_connect: hci0 dst 00:22:D0:10:13:EE
[14898.739429] [6603] hci_conn_add: hci0 dst 00:22:D0:10:13:EE
[14898.739434] [6603] hci_conn_init_sysfs: conn ffff880079f03000
[14898.739440] [6603] hci_send_cmd: hci0 opcode 0x200d plen 25
[14898.739443] [6603] hci_send_cmd: skb len 28
[14898.739487] [6603] hci_chan_create: hci0 conn ffff880079f03000
...
[14938.860231] [55] hci_send_cmd: hci0 opcode 0x200e plen 0
...
[14938.876427] [55] hci_le_conn_complete_evt: hci0 status 2
[14938.876433] [55] hci_conn_add: hci0 dst 00:00:00:00:00:00
[14938.876439] [55] hci_conn_init_sysfs: conn ffff88007aeff800
[14938.876454] [55] hci_send_to_control: len 14
[14938.876470] [55] l2cap_connect_cfm: hcon ffff88007aeff800 bdaddr 00:00:00:00:00:00 status 2
[14938.876474] [55] hci_conn_del: hci0 conn ffff88007aeff800 handle 0

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@tieto.com>
Acked-by: Andre Guedes <andre.guedes@openbossa.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: Return proper mgmt state when LE pairing connection failed
Andrzej Kaczmarek [Wed, 30 May 2012 13:39:22 +0000 (15:39 +0200)]
Bluetooth: Return proper mgmt state when LE pairing connection failed

MGMT_STATUS_BUSY should be returned when LE pairing cannot be started due
to another outgoing connection attempt is ongoing.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@tieto.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: Allow only one LE connection attempt
Andrzej Kaczmarek [Wed, 30 May 2012 13:39:21 +0000 (15:39 +0200)]
Bluetooth: Allow only one LE connection attempt

Only one outgoing LE connection attempt should be possible.
hci_connect() will now return -EBUSY in case there's another pending
outgoing connection.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@tieto.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: Remove unused err var from l2cap_segment_sdu()
Gustavo Padovan [Tue, 29 May 2012 16:29:17 +0000 (13:29 -0300)]
Bluetooth: Remove unused err var from l2cap_segment_sdu()

Trivial fix, let the code cleaner.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Reviewed-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
12 years agoBluetooth: Create function to return the ERTM header size
Gustavo Padovan [Tue, 29 May 2012 16:29:16 +0000 (13:29 -0300)]
Bluetooth: Create function to return the ERTM header size

Simplify the handling of different ERTM header size. We were the same
check in some places of the code, and more is expected to come, so just
replace them with a function.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Acked-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
12 years agoBluetooth: Make l2cap_att_channel return void
Andrei Emeltchenko [Thu, 31 May 2012 08:18:57 +0000 (11:18 +0300)]
Bluetooth: Make l2cap_att_channel return void

l2cap_att_channel always returns 0 which is not used.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: Make l2cap_conless_channel return void
Andrei Emeltchenko [Thu, 31 May 2012 08:18:56 +0000 (11:18 +0300)]
Bluetooth: Make l2cap_conless_channel return void

l2cap_conless_channel always return 0 which is not used.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: Make l2cap_data_channel return void
Andrei Emeltchenko [Thu, 31 May 2012 08:18:55 +0000 (11:18 +0300)]
Bluetooth: Make l2cap_data_channel return void

l2cap_data_channel always return 0 which is not used anywhere,
make it void function.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: A2MP: Do not reference hci_conn
Andrei Emeltchenko [Thu, 31 May 2012 08:01:37 +0000 (11:01 +0300)]
Bluetooth: A2MP: Do not reference hci_conn

Make A2MP channel special channel which do not reference hci_conn.
This prevents from keeping ACL connection open when all L2CAP
channels got closed.

hci_conn_hold and hci_conn_put are not reference counts on the
hci_conn structure in the typical way.  They are reference counts for
the ACL.  When you do the last hci_conn_put, the ACL is disconnected
after a timeout.

Reported-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: Do not check func ready existence
Andrei Emeltchenko [Wed, 30 May 2012 06:55:32 +0000 (09:55 +0300)]
Bluetooth: Do not check func ready existence

Functions will be always defined and in case not implemented as
dummy __no_func.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: Remove unused HCI timeouts definitions
Szymon Janc [Mon, 28 May 2012 09:47:20 +0000 (11:47 +0200)]
Bluetooth: Remove unused HCI timeouts definitions

Those are not used anywhere in code (and never were since introduction
in 2006) so just remove them.

Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: A2MP: Manage incoming connections
Andrei Emeltchenko [Tue, 29 May 2012 10:59:17 +0000 (13:59 +0300)]
Bluetooth: A2MP: Manage incoming connections

Handle incoming A2MP connection by creating AMP manager and
processing A2MP messages.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: A2MP: Handling fixed channels
Andrei Emeltchenko [Tue, 29 May 2012 10:59:16 +0000 (13:59 +0300)]
Bluetooth: A2MP: Handling fixed channels

A2MP fixed channel do not have sk

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: A2MP: Process A2MP Command Responses
Andrei Emeltchenko [Tue, 29 May 2012 10:59:15 +0000 (13:59 +0300)]
Bluetooth: A2MP: Process A2MP Command Responses

Process A2MP responses, print cmd code and ident for now.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: A2MP: Process A2MP Disc Physlink Request
Andrei Emeltchenko [Tue, 29 May 2012 10:59:14 +0000 (13:59 +0300)]
Bluetooth: A2MP: Process A2MP Disc Physlink Request

Placeholder for A2MP Disconnect Physlink Request.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: A2MP: Process A2MP Create Physlink Request
Andrei Emeltchenko [Tue, 29 May 2012 10:59:13 +0000 (13:59 +0300)]
Bluetooth: A2MP: Process A2MP Create Physlink Request

Placeholder for A2MP Create Physlink Request.
Handles requests with invalid controler id as shown below:

...
> ACL data: handle 11 flags 0x02 dlen 50
    A2MP: Create Physical Link req: local id 1 remote id 85
      Assoc data:
        <skipped>
< ACL data: handle 11 flags 0x00 dlen 15
    A2MP: Create Physical Link rsp: local id 85 remote id 1 status 1
      Invalid Controller ID
...

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: A2MP: Process A2MP Get AMP Assoc Request
Andrei Emeltchenko [Tue, 29 May 2012 10:59:12 +0000 (13:59 +0300)]
Bluetooth: A2MP: Process A2MP Get AMP Assoc Request

Example trace when receiving AMP Assoc Request with wrong AMP id.
...
> ACL data: handle 11 flags 0x02 dlen 13
    A2MP: Get AMP Assoc req: id 238
< ACL data: handle 11 flags 0x00 dlen 14
    A2MP: Get AMP Assoc rsp: id 238 status (1) Invalid Controller ID
      assoc data:
...

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: A2MP: Process A2MP Get Info Request
Andrei Emeltchenko [Tue, 29 May 2012 10:59:11 +0000 (13:59 +0300)]
Bluetooth: A2MP: Process A2MP Get Info Request

Process A2MP Get Info Request.
Example of trace log for invalid controller id is shown below:

...
> ACL data: handle 11 flags 0x02 dlen 13
    A2MP: Get Info req: id 238
< ACL data: handle 11 flags 0x00 dlen 30
    A2MP: Get Info rsp: id 238 status (1) Invalid Controller ID
...

Note that If the Status field is set to Invalid Controller ID all subsequent
fields in the AMP Get Info Response shall be ignored by the receiver.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: A2MP: Process A2MP Change Notify
Andrei Emeltchenko [Tue, 29 May 2012 10:59:10 +0000 (13:59 +0300)]
Bluetooth: A2MP: Process A2MP Change Notify

Placeholder for A2MP Change Notify handler.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: A2MP: Process A2MP Discover Request
Andrei Emeltchenko [Tue, 29 May 2012 10:59:09 +0000 (13:59 +0300)]
Bluetooth: A2MP: Process A2MP Discover Request

Adds helper functions to count HCI devs and process A2MP Discover
Request, code makes sure that first controller in the list is
BREDR one. Trace is shown below:

...
> ACL data: handle 11 flags 0x02 dlen 16
    A2MP: Discover req: mtu/mps 670 mask: 0x0000
< ACL data: handle 11 flags 0x00 dlen 22
    A2MP: Discover rsp: mtu/mps 670 mask: 0x0000
      Controller list:
        id 0 type 0 (BR-EDR) status 0x01 (Bluetooth only)
        id 1 type 1 (802.11 AMP) status 0x01 (Bluetooth only)
...

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: A2MP: Process A2MP Command Reject
Andrei Emeltchenko [Tue, 29 May 2012 10:59:08 +0000 (13:59 +0300)]
Bluetooth: A2MP: Process A2MP Command Reject

Placeholder for future A2MP Command Reject handler.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: A2MP: Process A2MP messages
Andrei Emeltchenko [Tue, 29 May 2012 10:59:07 +0000 (13:59 +0300)]
Bluetooth: A2MP: Process A2MP messages

Implement basic processing for AMP Manager Protocol (A2MP).

Example below shows processing unrecognized command.
...
> ACL data: handle 11 flags 0x02 dlen 12
    A2MP: code 0x00 ident 3 len 0
< ACL data: handle 11 flags 0x00 dlen 14
    A2MP: Command Reject: reason (0) - Command not recognized
...

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: A2MP: Define A2MP status codes
Andrei Emeltchenko [Tue, 29 May 2012 10:59:06 +0000 (13:59 +0300)]
Bluetooth: A2MP: Define A2MP status codes

A2MP status codes copied from Bluez patch sent by Peter Krystad
<pkrystad@codeaurora.org>.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: A2MP: Definitions for A2MP commands
Andrei Emeltchenko [Tue, 29 May 2012 10:59:05 +0000 (13:59 +0300)]
Bluetooth: A2MP: Definitions for A2MP commands

Define A2MP command IDs and packet structures.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: A2MP: Add chan callbacks
Andrei Emeltchenko [Tue, 29 May 2012 10:59:04 +0000 (13:59 +0300)]
Bluetooth: A2MP: Add chan callbacks

Add L2CAP chan ops callbacks.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: A2MP: Build and Send msg helpers
Andrei Emeltchenko [Tue, 29 May 2012 10:59:03 +0000 (13:59 +0300)]
Bluetooth: A2MP: Build and Send msg helpers

Helper function to build and send A2MP messages.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: A2MP: AMP Manager basic functions
Andrei Emeltchenko [Tue, 29 May 2012 10:59:02 +0000 (13:59 +0300)]
Bluetooth: A2MP: AMP Manager basic functions

Define AMP Manager and some basic functions.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: A2MP: Create A2MP channel
Andrei Emeltchenko [Tue, 29 May 2012 10:59:01 +0000 (13:59 +0300)]
Bluetooth: A2MP: Create A2MP channel

Create and initialize fixed A2MP channel

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: trivial: Use defined PSMLEN instead of magic
Andrei Emeltchenko [Tue, 29 May 2012 07:04:05 +0000 (10:04 +0300)]
Bluetooth: trivial: Use defined PSMLEN instead of magic

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: check for already existent channel before create new one
Gustavo Padovan [Mon, 28 May 2012 01:27:58 +0000 (22:27 -0300)]
Bluetooth: check for already existent channel before create new one

Move this check to before the channel time creation simplifies the code
and avoid memory allocation if the channel already exist.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Acked-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
12 years agoBluetooth: Move check for backlog size to l2cap_sock.c
Gustavo Padovan [Mon, 28 May 2012 01:27:55 +0000 (22:27 -0300)]
Bluetooth: Move check for backlog size to l2cap_sock.c

Remove socket specific code from l2cap_core.c

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Acked-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
12 years agoBluetooth: Use chan->state instead of sk->sk_state
Gustavo Padovan [Mon, 28 May 2012 01:27:54 +0000 (22:27 -0300)]
Bluetooth: Use chan->state instead of sk->sk_state

These vars are kept in sync so we can use chan->state here.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
12 years agoBluetooth: Add l2cap_chan->ops->ready()
Andrei Emeltchenko [Mon, 28 May 2012 01:27:53 +0000 (22:27 -0300)]
Bluetooth: Add l2cap_chan->ops->ready()

This move socket specific code to l2cap_sock.c.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
12 years agoBluetooth: Move clean up code and set of SOCK_ZAPPED to l2cap_sock.c
Andrei Emeltchenko [Mon, 28 May 2012 01:27:52 +0000 (22:27 -0300)]
Bluetooth: Move clean up code and set of SOCK_ZAPPED to l2cap_sock.c

This remove a bit more of socket code from l2cap core, this calls set the
SOCK_ZAPPED and do some clean up depending on the socket state.

Reported-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
12 years agoBluetooth: Use chan as parameters for l2cap chan ops
Gustavo Padovan [Mon, 28 May 2012 01:27:51 +0000 (22:27 -0300)]
Bluetooth: Use chan as parameters for l2cap chan ops

Use chan instead of void * makes more sense here.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
12 years agoBluetooth: Really fix registering hci with duplicate name
Sasha Levin [Sun, 27 May 2012 20:36:56 +0000 (22:36 +0200)]
Bluetooth: Really fix registering hci with duplicate name

Commit fc50744 ("Bluetooth: Fix registering hci with duplicate name") didn't
fully fix the duplicate naming issue with devices, and duplicate device names
could still be created:

[  142.484097] device: 'hci1': device_add
[...]
[  150.545263] device: 'hci1': device_add
[  150.550128] kobject: 'hci1' (ffff880014cc4e58): kobject_add_internal: parent: 'bluetooth', set: 'devices'
[  150.558979] ------------[ cut here ]------------
[  150.561438] WARNING: at fs/sysfs/dir.c:529 sysfs_add_one+0xb0/0xd0()
[  150.572974] Hardware name: Bochs
[  150.580502] sysfs: cannot create duplicate filename '/devices/virtual/bluetooth/hci1'
[  150.584444] Pid: 7563, comm: trinity-child1 Tainted: G        W    3.4.0-next-20120524-sasha #296
[...]

Instead of the weird logic and the attempt at keeping the device list sorted,
just use an IDA.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
12 years agoBluetooth: Use l2cap_chan_ready() in LE path
Gustavo Padovan [Fri, 25 May 2012 12:30:56 +0000 (09:30 -0300)]
Bluetooth: Use l2cap_chan_ready() in LE path

This replace code in l2cap_le_conn_ready() by a similar code in
l2cap_chan_ready().

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
12 years agoBluetooth: Remove extra l2cap_state_change(BT_CONNECTED)
Gustavo Padovan [Fri, 25 May 2012 12:30:53 +0000 (09:30 -0300)]
Bluetooth: Remove extra l2cap_state_change(BT_CONNECTED)

This is already performed inside l2cap_chan_ready(), so we don't need it
here again.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Acked-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
12 years agoBluetooth: Get a more accurate L2CAP PDU len
Gustavo Padovan [Fri, 25 May 2012 21:57:05 +0000 (18:57 -0300)]
Bluetooth: Get a more accurate L2CAP PDU len

Both FCS and Extended header might be or might not be present in a ERTM
channel.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Reviewed-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
12 years agoBluetooth: Define HCI AMP cmd struct
Andrei Emeltchenko [Fri, 25 May 2012 12:09:26 +0000 (15:09 +0300)]
Bluetooth: Define HCI AMP cmd struct

Add HCI commands to deal with Bluetooth AMP controllers.
Those commands will be used by bluetooth and softamp code.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
12 years agoBluetooth: Use __constant modifier in HCI code
Andrei Emeltchenko [Fri, 25 May 2012 08:38:27 +0000 (11:38 +0300)]
Bluetooth: Use __constant modifier in HCI code

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
12 years agoBluetooth: Use __constant when dealing with constants
Andrei Emeltchenko [Thu, 24 May 2012 12:42:51 +0000 (15:42 +0300)]
Bluetooth: Use __constant when dealing with constants

__constant_cpu_to_le16() is the right go here.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: Define and use PSM identifiers
Andrei Emeltchenko [Thu, 24 May 2012 12:42:50 +0000 (15:42 +0300)]
Bluetooth: Define and use PSM identifiers

Define assigned Protocol and Service Multiplexor (PSM) identifiers
and use them instead of magic numbers.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: Use lmp_ssp_capable() macro
Gustavo Padovan [Thu, 24 May 2012 06:36:37 +0000 (03:36 -0300)]
Bluetooth: Use lmp_ssp_capable() macro

Make the check more user friendly.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
12 years agoBluetooth: btmrvl: add SD8787 Bluetooth AMP device ID
Bing Zhao [Thu, 24 May 2012 01:50:04 +0000 (18:50 -0700)]
Bluetooth: btmrvl: add SD8787 Bluetooth AMP device ID

SD8787 SDIO function 3 (device ID 0x911B) is for Bluetooth AMP.

Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: Send a configuration request after security confirmation
Mat Martineau [Wed, 23 May 2012 21:59:30 +0000 (14:59 -0700)]
Bluetooth: Send a configuration request after security confirmation

Sometimes an ACL link must be raised to a higher security level after
an L2CAP connection is requested, but before a connection response is
sent.  In this case, a connection response sent by L2CAP was not
immediately followed by a configuration request.  Other code paths do
send this configuration request right away.  It was possible for the
connection to stall while L2CAP waited for the remote device (like
PTS) to trigger the configuration process.

Here is an abbreviated hcidump of the failure case with PTS:

1337806446.051982 > ACL data: handle 43 flags 0x02 dlen 10
    L2CAP(s): Info req: type 2
1337806446.052050 < ACL data: handle 43 flags 0x00 dlen 16
    L2CAP(s): Info rsp: type 2 result 0
      Extended feature mask 0x000000b8
1337806446.595320 > ACL data: handle 43 flags 0x02 dlen 12
    L2CAP(s): Connect req: psm 4097 scid 0x0041
1337806446.595673 < ACL data: handle 43 flags 0x00 dlen 16
    L2CAP(s): Connect rsp: dcid 0x0040 scid 0x0041 result 1 status 0
1337806446.595679 < ACL data: handle 43 flags 0x00 dlen 10
    L2CAP(s): Info req: type 2
1337806446.669835 > ACL data: handle 43 flags 0x02 dlen 16
    L2CAP(s): Info rsp: type 2 result 0
      Extended feature mask 0x00000028
1337806446.669899 < HCI Command: Authentication Requested (0x01|0x0011) plen 2
1337806446.669906 < ACL data: handle 43 flags 0x00 dlen 16
    L2CAP(s): Connect rsp: dcid 0x0040 scid 0x0041 result 1 status 1
<security setup here>
1337806446.769888 < ACL data: handle 43 flags 0x00 dlen 16
    L2CAP(s): Connect rsp: dcid 0x0040 scid 0x0041 result 0 status 0

At this point, the connection stalls and no further messages are sent
on the L2CAP signaling channel.  No data is received either.

If we immediately send a configuration request after a successful connect
response, the connection completes:

1337724090.041162 > ACL data: handle 43 flags 0x02 dlen 10
    L2CAP(s): Info req: type 2
1337724090.041236 < ACL data: handle 43 flags 0x00 dlen 16
    L2CAP(s): Info rsp: type 2 result 0
      Extended feature mask 0x000000b8
1337724090.597128 > ACL data: handle 43 flags 0x02 dlen 12
    L2CAP(s): Connect req: psm 4097 scid 0x0041
1337724090.597236 < ACL data: handle 43 flags 0x00 dlen 16
    L2CAP(s): Connect rsp: dcid 0x0040 scid 0x0041 result 1 status 0
1337724090.597244 < ACL data: handle 43 flags 0x00 dlen 10
    L2CAP(s): Info req: type 2
1337724090.660842 > ACL data: handle 43 flags 0x02 dlen 16
    L2CAP(s): Info rsp: type 2 result 0
      Extended feature mask 0x00000028
1337724090.660926 < HCI Command: Authentication Requested (0x01|0x0011) plen 2
1337724090.660934 < ACL data: handle 43 flags 0x00 dlen 16
    L2CAP(s): Connect rsp: dcid 0x0040 scid 0x0041 result 1 status 1
<security setup here>
1337724090.755162 < ACL data: handle 43 flags 0x00 dlen 16
    L2CAP(s): Connect rsp: dcid 0x0040 scid 0x0041 result 0 status 0
1337724090.755171 < ACL data: handle 43 flags 0x00 dlen 23
    L2CAP(s): Config req: dcid 0x0041 flags 0x00 clen 11
1337724091.361847 > ACL data: handle 43 flags 0x02 dlen 29
    L2CAP(s): Config rsp: scid 0x0040 flags 0x00 result 0 clen 15
1337724091.863808 > ACL data: handle 43 flags 0x02 dlen 23
    L2CAP(s): Config req: dcid 0x0040 flags 0x00 clen 11
1337724091.863882 < ACL data: handle 43 flags 0x00 dlen 29
    L2CAP(s): Config rsp: scid 0x0041 flags 0x00 result 0 clen 15
1337724092.683745 > ACL data: handle 43 flags 0x02 dlen 12
    L2CAP(d): cid 0x0040 len 8 [psm 4097]
      0000: 00 00 11 22 33 44 34 2f                           ..."3D4/

Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
12 years agoBluetooth: Define L2CAP conf continuation flag
Andrei Emeltchenko [Wed, 23 May 2012 12:44:06 +0000 (15:44 +0300)]
Bluetooth: Define L2CAP conf continuation flag

Define Continuation flag which the only flag used from Flags field
in L2CAP Configuration Request and Response.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
12 years agoBluetooth: Remove unneeded EXPORT_SYMBOL
Gustavo Padovan [Wed, 23 May 2012 07:04:23 +0000 (04:04 -0300)]
Bluetooth: Remove unneeded EXPORT_SYMBOL

After l2cap, sco and bluetooth modules merge some symbols doesn't need to
be exported anymore.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
12 years agoBluetooth: Remove unnecessary headers include
Gustavo Padovan [Wed, 23 May 2012 07:04:22 +0000 (04:04 -0300)]
Bluetooth: Remove unnecessary headers include

Most of the include were unnecessary or already included by some other
header.
Replace module.h by export.h where possible.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
12 years agoBluetooth: Fix coding style in the subsystem
Gustavo Padovan [Wed, 23 May 2012 07:04:21 +0000 (04:04 -0300)]
Bluetooth: Fix coding style in the subsystem

This is some leftover from the last patches that fixed style. It is mostly
line over 80 characters fixes reported by checkpatch.pl.
checkpatch.pl is clean for these files now.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
12 years agoBluetooth: Fix coding style in include/net/bluetooth
Gustavo Padovan [Wed, 23 May 2012 07:04:20 +0000 (04:04 -0300)]
Bluetooth: Fix coding style in include/net/bluetooth

Fix all warning and errors reported by checkpatch but license trailing
whitespace and bdaddr_t definition.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
12 years agoBluetooth: Remove 'register' usage from the subsystem
Gustavo Padovan [Wed, 23 May 2012 07:04:19 +0000 (04:04 -0300)]
Bluetooth: Remove 'register' usage from the subsystem

Let the compiler chooses what is best.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
12 years agoBluetooth: Remove most of the inline usage
Gustavo Padovan [Wed, 23 May 2012 07:04:18 +0000 (04:04 -0300)]
Bluetooth: Remove most of the inline usage

Only obvious cases were left as inline, mostly oneline functions.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
12 years agoBluetooth: trivial: Remove empty line
Andrei Emeltchenko [Wed, 23 May 2012 08:31:23 +0000 (11:31 +0300)]
Bluetooth: trivial: Remove empty line

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
12 years agoBluetooth: Preserve L2CAP flags values
Andrei Emeltchenko [Wed, 23 May 2012 08:31:22 +0000 (11:31 +0300)]
Bluetooth: Preserve L2CAP flags values

Previous callers of l2cap_build_conf_rsp in l2cap_config_req use
flags instead of continuation flag hardcoded value. It does not change
logic and preserve future possible flags.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
12 years agoBluetooth: Use defined link key size
Andrei Emeltchenko [Wed, 23 May 2012 08:31:20 +0000 (11:31 +0300)]
Bluetooth: Use defined link key size

Remove magic number with defined link key size.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
12 years agoBluetooth: Rename HCI_QUIRK_NO_RESET to HCI_QUIRK_RESET_ON_CLOSE
Szymon Janc [Wed, 23 May 2012 10:35:46 +0000 (12:35 +0200)]
Bluetooth: Rename HCI_QUIRK_NO_RESET to HCI_QUIRK_RESET_ON_CLOSE

HCI_QUIRK_NO_RESET name is misleading - purpose of this quirk is to
reset device on close instead of init, not to not reset at all.
Rename it to HCI_QUIRK_RESET_ON_CLOSE to avoid confusion.

Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
12 years agoBluetooth: Fix trailing whitespaces in license text
Gustavo Padovan [Tue, 22 May 2012 22:00:20 +0000 (19:00 -0300)]
Bluetooth: Fix trailing whitespaces in license text

As reported by checkpatch.pl

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
12 years agoBluetooth: Remove dead int returns
Gustavo Padovan [Mon, 21 May 2012 16:58:22 +0000 (13:58 -0300)]
Bluetooth: Remove dead int returns

These functions were returning always 0, we just make then void.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Reviewed-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
12 years agoBluetooth: Remove double check for BT_CONNECTED
Gustavo Padovan [Mon, 21 May 2012 16:58:21 +0000 (13:58 -0300)]
Bluetooth: Remove double check for BT_CONNECTED

The same check is done just before call l2cap_streaming_send()

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Reviewed-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
12 years agoBluetooth: Silent sparse warnings
Andrei Emeltchenko [Mon, 21 May 2012 12:47:46 +0000 (15:47 +0300)]
Bluetooth: Silent sparse warnings

Silence warnings below:

net/bluetooth/l2cap_core.c:1662:24: warning: Using plain integer
as NULL pointer
net/bluetooth/l2cap_core.c:1662:27: warning: Using plain integer
as NULL pointer
net/bluetooth/l2cap_core.c:1683:24: warning: Using plain integer
as NULL pointer
net/bluetooth/l2cap_core.c:1683:27: warning: Using plain integer
as NULL pointer
net/bluetooth/l2cap_core.c:2260:46: warning: Using plain integer
as NULL pointer
net/bluetooth/l2cap_core.c:2574:33: warning: Using plain integer
as NULL pointer
net/bluetooth/l2cap_core.c:2581:33: warning: Using plain integer
as NULL pointer
net/bluetooth/l2cap_core.c:4556:24: warning: Using plain integer
as NULL pointer
net/bluetooth/l2cap_core.c:4556:27: warning: Using plain integer
as NULL pointer

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: Do not purge queue in Basic Mode
Gustavo Padovan [Fri, 18 May 2012 23:22:38 +0000 (20:22 -0300)]
Bluetooth: Do not purge queue in Basic Mode

chan->tx_q is only initialized if we use ERTM or Streaming mode.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
12 years agoBluetooth: Enable ERTM by default
Mat Martineau [Fri, 18 May 2012 03:53:55 +0000 (20:53 -0700)]
Bluetooth: Enable ERTM by default

This enables the new receive and transmit state machines.

Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: Remove unused ERTM control field macros
Mat Martineau [Fri, 18 May 2012 03:53:54 +0000 (20:53 -0700)]
Bluetooth: Remove unused ERTM control field macros

Now that l2cap_ctrl is used to set up control fields, these macros are
not needed.

Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: Set txwin values for streaming mode
Mat Martineau [Fri, 18 May 2012 03:53:53 +0000 (20:53 -0700)]
Bluetooth: Set txwin values for streaming mode

The transmit window values must be configured for streaming mode, even
though streaming mode does not have a window.  This enables use of
extended headers when the transmit window socket option is set to 64
or larger.

Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: Remove unneccesary inline
Mat Martineau [Fri, 18 May 2012 03:53:52 +0000 (20:53 -0700)]
Bluetooth: Remove unneccesary inline

Let the compiler decide if inlining is appropriate.

Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: Simplify the ERTM ack timeout
Mat Martineau [Fri, 18 May 2012 03:53:51 +0000 (20:53 -0700)]
Bluetooth: Simplify the ERTM ack timeout

Since l2cap_send_ack can trigger extra actions like sending iframes,
don't call it.  Just send an RR or RNR frame if an ack needs sending.

Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: Use the ERTM transmit state machine from timeout handlers
Mat Martineau [Fri, 18 May 2012 03:53:50 +0000 (20:53 -0700)]
Bluetooth: Use the ERTM transmit state machine from timeout handlers

Different states have different actions for retransmit and monitor
timeouts, so remove the logic for those actions from the timer handlers.

Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: Check rules when setting retransmit or monitor timers
Mat Martineau [Fri, 18 May 2012 03:53:49 +0000 (20:53 -0700)]
Bluetooth: Check rules when setting retransmit or monitor timers

The ERTM specification requires the retransmit timer to be cancelled
when the monitor timer is set.  The retransmit timer cannot be set
again while the monitor timer is pending.

Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: Use new header structures in l2cap_send_rr_or_rnr
Mat Martineau [Fri, 18 May 2012 03:53:48 +0000 (20:53 -0700)]
Bluetooth: Use new header structures in l2cap_send_rr_or_rnr

struct l2cap_ctrl is now used, and the sframe is now sent directly
rather than depending on a separate call.

Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: Handle incoming REJ frames
Mat Martineau [Fri, 18 May 2012 03:53:47 +0000 (20:53 -0700)]
Bluetooth: Handle incoming REJ frames

REJ frames are sent by the remote device to request that all frames
after a given sequence number be retransmitted.  These are also an
implicit indication that the remote device is not in a busy state and
can receive new iframes.

Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: Handle SREJ requests to resend unacked frames
Mat Martineau [Fri, 18 May 2012 03:53:46 +0000 (20:53 -0700)]
Bluetooth: Handle SREJ requests to resend unacked frames

When a remote device sends an SREJ, retransmit the frame with the
corresponding sequence number (subject to special cases with poll and
final flags).  An SREJ is also an implicit indication the the remote
device is not in a busy state.

Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: Reassemble all available data when retransmissions succeed.
Mat Martineau [Fri, 18 May 2012 03:53:45 +0000 (20:53 -0700)]
Bluetooth: Reassemble all available data when retransmissions succeed.

As retransmitted packets arrive, attempt to reassemble SDUs.  If all
requested retransmissions have been received, acknowledge them and
transition back to the RECV state.

Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: Send SREJ frames when packets go missing
Mat Martineau [Fri, 18 May 2012 03:53:44 +0000 (20:53 -0700)]
Bluetooth: Send SREJ frames when packets go missing

The ERTM specification lays out three scenarios for sending SREJ
frames to request retransmission of specific frames.  l2cap_send_srej
requests all frames up to a given txseq that are not already queued
for reassembly.  l2cap_send_srej_tail only requests the most recent
missing frame.  l2cap_send_srej_list resends SREJ frames for data that
was requested for resend but never received.

Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: Add implementation for retransmitting all unacked frames
Mat Martineau [Fri, 18 May 2012 03:53:43 +0000 (20:53 -0700)]
Bluetooth: Add implementation for retransmitting all unacked frames

This adds l2cap_ertm_resend to retransmit frames based on the sequence
numbers in chan->retrans_list.  If the retransmit limit is reached for
any individual frame is reached, the connection is dropped.  skbs that
are cloned already are copied to avoid modifying shared data (this is
uncommon).  To retransmit all frames, l2cap_retransmit_all now builds
a list of all unacked sequence numbers and then calls
l2cap_ertm_resend.

Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: Add the ERTM receive state machine
Mat Martineau [Fri, 18 May 2012 03:53:42 +0000 (20:53 -0700)]
Bluetooth: Add the ERTM receive state machine

This adds a top-level state machine with handlers for two receive
states defined in the ERTM spec, RECV and SREJ_SENT.  The reqseq value
of the incoming frame is also validated at the top level and a
disconnection is forced if it is invalid.  The actions for the RECV
and SREJ_SENT states are implemented according to the state tables in
the ERTM specification.

Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: Update l2cap_send_i_or_rr_or_rnr to fit the spec better
Mat Martineau [Fri, 18 May 2012 03:53:41 +0000 (20:53 -0700)]
Bluetooth: Update l2cap_send_i_or_rr_or_rnr to fit the spec better

This action now exactly matches what is defined in the ERTM
specification, including clearing the remote busy flag and setting the
retransmit timer rather than retransmitting frames directly.  The spec
does not retransmit frames as part of this action, since
retransmission is only triggered by REJ, SREJ, or an RR with the final
bit set.  struct l2cap_ctrl is also used to set up header values.

Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: Use the transmit state machine for busy state changes
Mat Martineau [Fri, 18 May 2012 03:53:40 +0000 (20:53 -0700)]
Bluetooth: Use the transmit state machine for busy state changes

This lets the transmit state machine handle local busy state changes,
since different actions are taken in the different transmit states.

Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: Refactor l2cap_send_ack
Mat Martineau [Fri, 18 May 2012 03:53:39 +0000 (20:53 -0700)]
Bluetooth: Refactor l2cap_send_ack

The function now encapsulates more of the logic to either immediately
send an ack if the transmit window is over 75% full, or wait for the
ack timer to expire if the transmit window is not full enough.  It is
also able to push out waiting iframes that can carry an
acknowledgement.

Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: Remove receive code that has been superceded
Mat Martineau [Fri, 18 May 2012 03:53:38 +0000 (20:53 -0700)]
Bluetooth: Remove receive code that has been superceded

This deletes the receive code that had handlers for each frame type at
the top level, and then had logic to determine the receive state
within each handler.

Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
12 years agoBluetooth: Add streaming mode receive and incoming packet classifier
Mat Martineau [Fri, 18 May 2012 03:53:37 +0000 (20:53 -0700)]
Bluetooth: Add streaming mode receive and incoming packet classifier

Streaming mode reception is fairly simple, with in-sequence frames
being reassembled as they arrive.  Out-of-sequence frames are dropped,
and also clear any partially-assembled SDUs that may exist.

The packet classifier determines if the txseq value of the incoming
packet is expected, invalid (resulting in a disconnection), invalid
(ignorable), duplicate, or having to do with an SREJ request that was
previously sent.  The rules for each classification are defined in the
ERTM specification, and consolidating these rules in one place helps
clarify the receive state machine.

Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>