Commit graph

41176 commits

Author SHA1 Message Date
Johan Hedberg
2b68871f7c Bluetooth: uart: Fix discarding data in case of too small buffer
Even if a buffer can't hold the needed amount of data we should still
cleanly discard the bytes so that the driver doesn't loose sync of the
next packet boundary. This way we also get to remove the now
unnecesary 'failed' label.

Change-Id: Ic921fbf6c0ddef4a7721cee7fa3e01a31b127778
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:40 -05:00
Johan Hedberg
b620f6a5ae net: samples/buf: Fix Kconfig option name
Change-Id: Ib120b2a746aa319b7c0ea943e23a83b45aefaf31
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:40 -05:00
Luiz Augusto von Dentz
701404624e Bluetooth: L2CAP: Don't limit tx MTU
This store the original MTU sent by the remote instead of limiting it to
the amount the buffer can allocate since buffer sizes can now be
different and it was anyway wrong to assume the size of buffer used for
signalling would be the same as in data packets.

Change-Id: I52c7e4946ae949a0068ce28a00d2b427a48a1b51
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:24:40 -05:00
Luiz Augusto von Dentz
b861797736 Bluetooth: Fix not unreferencing buffer
Buffer received over L2CAP dynamic channels needs to be unref by the
application once they are done with it.

Change-Id: If210be1c538cf0b550dd03094d007b6851cdfbf4
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:24:40 -05:00
Johan Hedberg
c73a6fd017 Bluetooth: Adjust lower bound of HCI command size
Currently the biggest required HCI command is HCI_LE_Generate_DHkey
which needs 1 (H4 header) + 3 (cmd header) + 64 = 68 bytes.

Change-Id: Ice142b7c68c1cb1571e03549bceb301d806bc453
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:40 -05:00
Jukka Rissanen
db51867a2b net: Fix NET_BUF_ASSERT macro compile error
This commit fixes this compile error if network buffer debugging
is activated.

  CC      net/buf.o
net/buf.c: In function 'net_buf_unref':
net/buf.c:40:31: error: expected expression before 'if'
 #define NET_BUF_ASSERT(cond) (if (!(cond)) {    \
                               ^
net/buf.c:81:2: note: in expansion of macro 'NET_BUF_ASSERT'
  NET_BUF_ASSERT(buf->ref > 0);
  ^

Change-Id: Id4248806a5df571663e47eab581164a16df0cd1b
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:24:40 -05:00
Johan Hedberg
9350318b92 Bluetooth: core: Rename buffer user data more appropriately
The structs are private so there's no need for long name-spacing.
Also, the bt_hci_data is only used for commands, so just call it
cmd_data.

Change-Id: I924a5b8a8cbcb9eb56038a83c03bcbcf7e79b6e0
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:40 -05:00
Johan Hedberg
297f4f481f Bluetooth: Split HCI command & event buffers to two pools
The HCI commands and events have slightly different requirements
(e.g. max sizes, or the fact that events don't need any user data) so
it makes sense to keep them separate. The total count is kept at 8 (2
+ 6) but the ACL_OUT count is modified to not exceed the event count
(to avoid inability of handling bursts of Number of Completed Packets
events). The ACL_IN count is also modified to keep these symmetric for
now.

Change-Id: Ia1915a596424425525b6df67e0ddce47a7f618f3
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:40 -05:00
Johan Hedberg
eaa34b0753 Bluetooth: Fix using correct host ACL buffer count
The BT_BUF_ACL_IN_MAX was a left-over that shouldn't be used anymore.

Change-Id: Ifa15e00e7e72f56670961ca7830595a2b4301093
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:40 -05:00
Johan Hedberg
e9ceedcff7 Bluetooth: Introduce config options for buffer counts/sizes
Introduce dedicate Kconfig options for ACL & HCI buffer counts and
sizes.

Change-Id: I96796058f70998e1e721849422c4bc4e950b6d93
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:40 -05:00
Johan Hedberg
fc6b853211 Bluetooth: Clean up Kconfig
Clean up Kconfig conventions.

Change-Id: I06df0b6363cd2dab72e93456455aaef219340e4d
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:40 -05:00
Szymon Janc
5fe86c9452 Bluetooth: Fix typo in NET_BUF Kconfig option description
Change-Id: If4249f20a0ec8a6634eaf3c9b9ea1b605b22a2e7
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:24:40 -05:00
Szymon Janc
c84d05a3fe Bluetooth: Allow to enable debugs without connection support
BLUETOOTH_DEBUG and BLUETOOTH_DEBUG_HCI_CORE options are also useful
for Broadcaster and Observer roles and should not depends on connection
support.

Change-Id: Ice1142f3dcc5d73e5460449cc1444a1345eb624a
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:24:40 -05:00
Szymon Janc
ea513bb569 Bluetooth: Always compile in UUID support
This is also useful for Broadcaster and Observer roles and shouldn't
depend on connection support.

Change-Id: I85003253455c3949344e26d24a5fb3a718115947
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:24:40 -05:00
Jukka Rissanen
6b17c489d4 net: Rename samples/microkernel/apps/network
Networking code is in net directory in other parts of the
code base so rename network -> net in samples/microkernel/apps
directory.

Change-Id: Ic89d4616a28b4079f90351938f9798c7bf61ce05
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:24:40 -05:00
Jukka Rissanen
b14e623918 net: Rename samples/nanokernel/apps/network
Networking code is in net directory in other parts of the
code base so rename network -> net in samples/nanokernel/apps
directory.

Change-Id: I5684f569f75aa0a9d66128cf786e60ced79fbaf0
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:24:40 -05:00
Jukka Rissanen
bd5d503fc6 net: Rename samples/network to samples/net
Networking code is in net directory in other parts of the
code base so rename network -> net in samples directory.

Change-Id: I0ca0188c6844b0957270398d08b85a3153819e97
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:24:39 -05:00
Johan Hedberg
4b433d4fa6 Bluetooth: Differentiate send/recv of needed driver headroom
The space that the HCI driver needs to reserve for its own use is not
necessarily symmetrical. E.g. even with the current H4 driver we only
need to reserve space for sending data but not for receiving it.
Keeping track of these values independently enables more efficient use
of the buffers.

Change-Id: I64917b545c5cd77356ed038d09afe76422334661
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:39 -05:00
Ravi kumar Veeramally
1c0c1e4a00 net: apps: Add sanity test changes to test_15_4
Add sanity test related changes to test_15_4 application in both
micro and nano kernel. config_whitelist in testcase.ini is not
accepting other than PLATFORM configs. So creating test folder
for sanity tests. src directory is still common for all.

Change-Id: Iffa4c588500367fa475aef8e0772f1c08946c5a4
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-02-05 20:24:39 -05:00
Ravi kumar Veeramally
a81c968b0b net: Add Kconfig option for sanity test
Change-Id: I9d1742fb2c70fbba573fe9ed64bedd8a76aa504c
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-02-05 20:24:39 -05:00
Ravi kumar Veeramally
694d972595 net: apps: Add support for CONFIG_NET_15_4_LOOPBACK_NUM
Add support for CONFIG_NET_15_4_LOOPBACK_NUM in test_15_4 application.

Change-Id: I57246f9db587f492cddc0d0be607b1ae4a78fbf7
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-02-05 20:24:39 -05:00
Johan Hedberg
fa8636c24e Bluetooth: Fix handle value in completed packets command
The report_completed_packet() function overwrites the original buf
pointer so we have to use a local variable to store the handle value.

Change-Id: I9caada0dd83270f2de998f57940aaf4995a247da
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:39 -05:00
Johan Hedberg
13fcc5ca3e Bluetooth: Make ACL/HCI user data private to hci_core.c
Change-Id: I85ccbfd2d844195bffcc6dd3d6490808569ca129
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:39 -05:00
Johan Hedberg
52cf66feb9 Bluetooth: Remove user data from outgoing ACL buffers
Outgoing ACL buffers don't need any user data.

Change-Id: If7e6a27b88d3aa64c51672190bdecc705429aa7b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:39 -05:00
Johan Hedberg
31114c384b Bluetooth: Remove buffer type information from user data
Since the type can be determined either from the context or from e.g.
the pool that it belongs to (the 'free' pointer) we no-longer need to
store the type as part of the user data struct.

Change-Id: I090636aaa0a0b1be798b6dadfab072151fc3ab14
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:39 -05:00
Johan Hedberg
5f4daa1551 Bluetooth: Merge send_acl/cmd back to a single callback
Now that we have the buffer type enum as part of the HCI driver API we
can take advantage of it to pass the buffer type information and not
have to have two separate callbacks.

Change-Id: Ib2ee5b1540e532c9b27903e97660a276c1293fbc
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:39 -05:00
Johan Hedberg
ff2d104105 Bluetooth: Move buffer type enum to driver.h
Since the buffer type is essentially a HCI driver - HCI core
communication detail the appropriate place for it is driver.h. At the
same time remove the unnecessary and slightly confusing BT_DUMMY type.

Change-Id: Ic813ad24d8f0530d3779006063ea21b010d29cf6
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:39 -05:00
Johan Hedberg
e000290627 Bluetooth: Move outgoing ACL buffer management to l2cap.c
The only user of this is l2cap.c so move the buffer pool there to
avoid unnecessary calls between c-files.

Change-Id: Ia9335b21c34546e2252fa40d9eec2e09156b0d67
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:39 -05:00
Johan Hedberg
3822aecd24 Bluetooth: Merge buf.[ch] functionality into hci_core.[ch]
There's no need to maintain a separate module for this anymore.
Subsequent patches will have further simplifications thanks to this
being now handled in a single c-file.

Change-Id: I4510c9f72b121e1e5fd19eeb8b5d5ddf2f4bfffe
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:39 -05:00
Johan Hedberg
1ddc3edcaa Bluetooth: Introduce HCI-driver specific buffer functions
This way we avoid dealing with the specific buffer type value and to
make it clear that these are for drivers onle.

Change-Id: I8aef7ec6a767b2fa68cbe374eb371e2a6192f675
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:39 -05:00
Johan Hedberg
7ff1cbd976 Bluetooth: Split HCI driver ACL/CMD send callback
This is a necessary step in preparation for removing the buffer type
information from the buffers.

Change-Id: I29d8fae32aa660416a1c12e87840499c711e659f
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:39 -05:00
Johan Hedberg
70f80ad968 Bluetooth: samples/peripheral: Remove dependency on internal define
Change-Id: I514d9beb69c27e563d7daeaa880ba55b49a6f159
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:39 -05:00
Szymon Janc
51af39ff16 Bluetooth: Allow sanity to build tester on x86
This allows to build sanity for both ARM and x86 archs.
Only supported platforms are enabled.

Change-Id: I499dbdee7b9df265affb2bba98b5bb100339fe18
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:24:39 -05:00
Ravi kumar Veeramally
34f1cacae3 net: Add Kconfig option for loopback num
NET_15_4_LOOPBACK_NUM is Kconfig option for number of times
loopback runs. In a controllable way loopback runs. This will
be helpful in sanity tests.

Change-Id: I48392d7e0d0b793ddc1b2b0c1b8c1f22e1bb318a
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-02-05 20:24:39 -05:00
Ravi kumar Veeramally
5e965ca8ca net: apps: Remove unused nanosems
Change-Id: I0c62ad9919d5915438a85adc4a2afcca8e23950a
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-02-05 20:24:39 -05:00
Ravi kumar Veeramally
4d705eec5c net: Fix net_buf variable initialization
Variable len is related uIP stack. datalen is actual variable which
needs to be set zero in net_buf_get_reserve.

Change-Id: I75273ef760d3cd4f90808b496b75f56f19bd2e2b
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-02-05 20:24:39 -05:00
Szymon Janc
162b5e8091 Bluetooth: Default to ARM build for tester application
Tester application requires 3 UARTs and currently no x86 based
platform supports it. For convenience default to arch that allows
to run, not only build tester.

Change-Id: I086e72a580f56d94181a6d6eada7693ddd24dec1
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:24:39 -05:00
Johan Hedberg
f1baa0b8fc Bluetooth: uart: Remove incorrect buffer type check
It's invalid to try to send HCI events to the controller so we should
treat such buffer types as invalid in bt_uart_send().

Change-Id: I4108a158d5b91f364a9f3c56e3037f03755daa19
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:39 -05:00
Johan Hedberg
0c338649f0 Bluetooth: Remove unnecessary deadlock check
Previously we didn't have the split to priority rx fiber vs "normal"
rx fiber. This meant that we didn't have full control of code that
would run from this fiber and therefore a deadlock check was useful.
The rx priority fiber (where the deadlock could happen) is very well
defined and controlled so the value of this extra check is now quite
minimal.

Change-Id: I8d09cc39ca6548230a973bc8b8231d999dc1dc67
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:39 -05:00
Johan Hedberg
ea11d4b5cd Bluetooth: Add helper macros for accessing Bluetooth user data
To avoid unnecessary stack variables and to simplify code, add helper
macros to access the Bluetooth specific ACL and HCI user data that's
part of the buffers.

Change-Id: Idc337537721115c4091982c04f8a05bbbf0d5a19
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:39 -05:00
Johan Hedberg
6e84d77151 Bluetooth: Remove old bt_buf API
Now that all code is converted remove the temporary helpers for the
old bt_buf API.

Change-Id: I5183add527d204c51103549fda3378040d5f8f68
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:39 -05:00
Johan Hedberg
48fde83fe5 Bluetooth: samples/test_bluetooth: Convert to net_buf API
Convert the code to use the net_buf API instead of the soon to be
removed bt_buf API.

Change-Id: I98a0720483d3f364b77fe6dc030c9169aa4ade67
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:39 -05:00
Johan Hedberg
e41285999c Bluetooth: samples/shell: Convert to net_buf API
Convert the code to use the net_buf API instead of the soon to be
removed bt_buf API.

Change-Id: I4eb6cea592cce99dcc9e4c1b1219ebbf89eddd04
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:39 -05:00
Johan Hedberg
ad20899261 Bluetooth: gatt: Convert to net_buf API
Convert the code to use the net_buf API instead of the soon to be
removed bt_buf API.

Change-Id: I9437750aa6fffcde31e1879bf6e3a13143f45480
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:39 -05:00
Johan Hedberg
b9476947d9 Bluetooth: att: Convert to net_buf API
Convert the code to use the net_buf API instead of the soon to be
removed bt_buf API.

Change-Id: I89e5ac5a178cf57c0a3f7fee38d1170c25e07c5b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:38 -05:00
Johan Hedberg
dfdd7b24de Bluetooth: smp: Convert to net_buf API
Convert the code to use the net_buf API instead of the soon to be
removed bt_buf API.

Change-Id: I3c7f6c5ec2b447adc8855acf8d66205434ce08eb
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:38 -05:00
Johan Hedberg
529a12338b Bluetooth: l2cap: Convert to net_buf API
Convert the code to use the net_buf API instead of the soon to be
removed bt_buf API.

Change-Id: I5f376caeb861ac8b815a0a2e235bd188b9e8185b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:38 -05:00
Johan Hedberg
5b4063094a Bluetooth: conn: Convert to net_buf API
Convert the code to use the net_buf API instead of the soon to be
removed bt_buf API.

Change-Id: I7f4577ba31f8e5646873f164ff308c71d23021e5
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:38 -05:00
Johan Hedberg
c73b131b3b Bluetooth: core: Convert to net_buf API
Convert the code to use the net_buf API instead of the soon to be
removed bt_buf API.

Change-Id: I226de212d4f8d4f5b613708ffe42570443bc2182
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:38 -05:00
Johan Hedberg
1f01f1da16 Bluetooth: uart: Convert to net_buf API
Convert the code to use the net_buf API instead of the soon to be
removed bt_buf API.

Change-Id: I8df37d214e1f93ee472cde82c4198d667709ff5a
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:38 -05:00