Commit graph

18591 commits

Author SHA1 Message Date
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
Johan Hedberg
581fa90ea8 Bluetooth: Initial conversion to net_buf API
This patch performs the minimal necessary conversion to the net_buf
API. It uses a temporary "#define bt_buf net_buf" to make it possible
to convert the code in smaller increments. Most old bt_buf function
also serve as one-line wrappers to the matching net_buf APIs. Once
everything is converted these helpers will be removed.

Change-Id: Ie31433d33576022c9c193a35d2389267005545d6
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:38 -05:00
Johan Hedberg
c1f007687f net: Add initial generic buffer implementation
We need to have a generic buffer API in order to efficiently transfer
data between different subsystems. The first such case will be the
Networking and Bluetooth subsystems where 6LoWPAN data will be passed
back and forth.

The needed API needs to provide enough flexibility for different
buffer sizes as well as custom protocol-specific context data.

The implementation offered in this patch follows the general design of
the existing Networking and Bluetooth buffer implementations by using
a backing array of buffer which is fed into a "free buffers" FIFO for
management. The main difference is that the API allows specifying
variable sized buffers for each created pool, as well as a minimum
amount of "user data" that's allocated as part of each buffer.

There's also an optional destroy callback that's e.g. useful for HCI
flow control in Bluetooth (for notifying the controller of available
buffers).

Change-Id: I00b7007135a0ff35219f38f48658f31728fbb7ca
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:38 -05:00
Luiz Augusto von Dentz
d57e54fddc Bluetooth: Make it possible to build tester for x86
Currently it is only possible to build the tester for arm.

Change-Id: I7fd530ca09bfa41072420da774fba3b48a5d5a90
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:24:38 -05:00
Luiz Augusto von Dentz
929d4f4c86 Bluetooth: GATT: Make BT_GATT_CHARACTERISTIC declare its value
This makes BT_GATT_CHARACTERISTIC declare a local bt_gatt_chrc so the
applications don't need to declare themselves.

Change-Id: Icf3fad7dffea5667c6f13aa022a5722900da51e8
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:24:38 -05:00
Luiz Augusto von Dentz
1617f5580b Bluetooth: GATT: Remove value_handle from bt_gatt_chrc
The spec says it should always be the very first descriptor after the
characteristic:

  "BLUETOOTH SPECIFICATION Version 4.2 [Vol 3, Part G] page 534:
   3.3.2 Characteristic Value Declaration
   The Characteristic Value declaration contains the value of the
   characteristic. It is the first Attribute after the characteristic
   declaration. All characteristic definitions shall have a
   Characteristic Value declaration."

Change-Id: I6c38dea9cc4c1a05997edbd348e2759680472725
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:24:38 -05:00
Luiz Augusto von Dentz
148ce3013c Bluetooth: GATT: Remove unused field of _bt_gatt_ccc
value_handle is not used for anything.

Change-Id: I3885d221b162eb3bd44956af64280baf61dc001b
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:24:38 -05:00
Luiz Augusto von Dentz
1284e608ac Bluetooth: GATT: Remove handles from macros
bt_gatt_register will assign a handle if not initialized and removing
the handle makes it simpler to change the attributes since it is no
longer possible to have conflicting handles.

Change-Id: I787f7325cc990c360056b1aefd07bb7d7876b445
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:24:38 -05:00
Luiz Augusto von Dentz
1c8ab98114 Bluetooth: GATT: Make attribute database into a list
This allow calling bt_gatt_register multiple times so different tasks
can add their own services separately.

Change-Id: I8143ddedfa1079087d608013d1a97b552a3007dc
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:24:38 -05:00
Michael LeMay
2a11205499 net: apps: echo_server: Add Ethernet support
This patch adds a NET_INTF makefile configuration option to the
echo_server sample application to allow Ethernet support to be enabled
by specifying NET_INTF=ethernet.  It currently includes specific
support for the Ethernet device in the Intel Galileo.

Change-Id: I6b605db32d2d8a4259fc003724b2daa11c9a26d9
Signed-off-by: Michael LeMay <michael.lemay@intel.com>
2016-02-05 20:24:38 -05:00
Michael LeMay
ef2a2254e6 eth: dw: galileo: Provide pre-set MMIO base address and IRQ
Provide a preconfigured base address for MMIO and a preconfigured IRQ
pin identifier for the first PCI Ethernet MAC in the Intel Quark X1000
SoC.

Change-Id: I1b527df6c3b1b65da9f0233464e54157029f04f5
Signed-off-by: Michael LeMay <michael.lemay@intel.com>
2016-02-05 20:24:38 -05:00
Michael LeMay
ebba3bf38b eth: dw: Add driver for Synopsys DesignWare Ethernet MAC
This patch adds a driver for a Synopsys DesignWare Ethernet MAC.  The
driver uses interrupts to handle received frames, but it uses a
spinloop when transmitting to wait for the transmit descriptor to
become available.  Transmission is coordinated by a fiber, so this
should not result in the system execution being blocked.  Only a
single descriptor is allocated for each of the transmit and receive
directions to save memory and simplify the code.  Another
simplification is that none of the offload capabilities of the
Ethernet device are used.  The driver currently only supports a single
instance of the Ethernet MAC, which is consistent with the limitation
in the network stack that only a single network device is supported.

Change-Id: I013b3d439a76e8ff91a775516f7035841b040870
Signed-off-by: Michael LeMay <michael.lemay@intel.com>
2016-02-05 20:24:38 -05:00
Michael LeMay
0927378a59 net: Add Ethernet support to the network stack
This patch adds support for Ethernet to the network stack, which
entails relying on the Ethernet device driver to set the MAC address,
invoking ARP routines at the appropriate points, configuring the
Contiki network stack to use the appropriate link-level header length,
etc.

Change-Id: I153a6f4c83c28ca7129ef5affa1e9a18b0f92913
Signed-off-by: Michael LeMay <michael.lemay@intel.com>
2016-02-05 20:24:38 -05:00
Michael LeMay
2684f4472f pci: Add pci_enable_bus_master
This patch adds the pci_enable_bus_master function that enables bus
master access for a PCI device.

Change-Id: I317daac1a613ccfc5a3894332c1a7dbbff05991f
Signed-off-by: Michael LeMay <michael.lemay@intel.com>
2016-02-05 20:24:38 -05:00
Johan Hedberg
b7ae2f44ad net: Fix enabling both Bluetooth and Networking support
We can't use '=' in net/Makefile since then one statement would
override the value of the previous one when both CONFIG_NETWORKING and
CONFIG_BLUETOOTH were set to 'y'. Instead, use '+='.

Change-Id: Idba9916cc9fb2bd0e53975bdf0a86c0fd184533c
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:38 -05:00
Johan Hedberg
49885879f2 Bluetooth: Rename bt_conn_get/put to bt_conn_ref/unref
We want to make the naming convention ref/unref rather than get/put.
So far the only reference counted objects are the buffers and the
connections. For the buffers the new generic buffer API will also use
ref/unref.

Change-Id: I9fe8b8a6a50a8baf06ba231e8f6717a5a47dd292
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:38 -05:00
Luiz Augusto von Dentz
6f410176ef Bluetooth: Make bt_uuid_str parameter const
bt_uuid_to_str uuid param is const therefore bt_uuid_str should be const
as well.

Change-Id: I043d66d16c863ed92e60477dbbb9c37bcde92703
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:24:38 -05:00
Luiz Augusto von Dentz
48cbd12ffb Bluetooth: Fix UUID 128 bits string format
The two last fields are 32 bits and 16 bits respectively not the other
way around.

Change-Id: I10d2ed9d69229f02b430f9812e95e4a8f3f060c7
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:24:38 -05:00
Mariusz Skamra
13e0178c55 Bluetooth: Add support for writting characterisitc value
This adds write and flush attribute callbacks to be used for writting
attribute values.
With this patch lower tester can test if IUT can properly handle
write request to the characteristic values.

> ACL Data RX: Handle 64 flags 0x02 dlen 7  [hci0] 1151923.440823
      ATT: Read Request (0x0a) len 2
        Handle: 0x0003
< ACL Data TX: Handle 64 flags 0x00 dlen 7  [hci0] 1151923.456050
      ATT: Read Response (0x0b) len 2
        Value: bbbb
> ACL Data RX: Handle 64 flags 0x02 dlen 9  [hci0] 1151928.435525
      ATT: Write Request (0x12) len 4
        Handle: 0x0003
          Data: ffff
< ACL Data TX: Handle 64 flags 0x00 dlen 5  [hci0] 1151928.456865
      ATT: Write Response (0x13) len 0
> ACL Data RX: Handle 64 flags 0x02 dlen 7  [hci0] 1151929.380796
      ATT: Read Request (0x0a) len 2
        Handle: 0x0003
< ACL Data TX: Handle 64 flags 0x00 dlen 7  [hci0] 1151929.394636
      ATT: Read Response (0x0b) len 2
        Value: ffff

Change-Id: Iea1d39e1a52496692141411251fd4ac2f9ae0b97
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:24:38 -05:00
Mariusz Skamra
1fa60d7a5e Bluetooth: Fix set value command handler
If the attribute value is going to be changed by the upper tester,
(eg. to issue notification) for simplicity it can be stored in the
place of old one.

Change-Id: I03a6ebbda5d75e6ffa9c2fd6b3c0eab495623a11
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:24:38 -05:00
Johan Hedberg
79bd18e683 Bluetooth: uart: Remove dead code
There's no point in having a return value for uart_out() if it always
returns the same length that was passed to it. Just make it return
void and remove the error handling code from the caller (which would
never have been run).

Change-Id: I88dab7499a5f526ca65058640021f84e1b3486ca
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:38 -05:00
Andrei Emeltchenko
82f33267c5 Bluetooth: Change fifo_fill to poll_out
The reason why fifo_fill works in qemu but not on real hardware is
that qemu serializes all byte transmission 1 by 1. There is no
real hardware fifo emulated, and "fifo" depth is 1. On real
hardware, the controller owns an internal fifo, with a depth like
8 bytes on Quark x1000. And because of execution flow, how fast is
the controller etc etc... a fifo_fill call might fill in the
internal fifo of 8 bytes and then controller says "I am full"
(which means: "wait for the fifo to have space again"). That's
why poll_out() works: it does the same as fifo_fill and wait
that the internal fifo gets some space again before continuing.
And only when all bytes have been pushed in, it returns.

Change-Id: I452a6ebb2913c5e52ed01d999185e250aa3ed474
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:24:38 -05:00
Michael LeMay
ac00cd4e37 net: Adapt return value from network driver send routine
This patch fixes a potential issue in which the signed return value
from the network driver send routine is returned from a caller that
has an unsigned return type.  The meaning of a negative return value
from the network driver send routine is that an error occurred.  A
return value of 1 means that the packet was sent successfully.  A
return value of 0 means that the packet could not be sent.  Thus, this
patch converts negative return values from the network driver send
routine to a return value of 0 from the caller.

Change-Id: If5cbecb18e514fd976200ecc45782d2a9e1f300f
Signed-off-by: Michael LeMay <michael.lemay@intel.com>
2016-02-05 20:24:38 -05:00
Luiz Augusto von Dentz
6cb42e1e20 Bluetooth: Make use of bt_uuid_to_str
This make use of bt_uuid_to_str to when printing UUID values, to make it
simpler when it is just going to print so the patch introduces a new
function that does the conversion in place using a static variable.

Change-Id: Idfedf05a5ad201653fff2e01387f046cd5647c83
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:24:37 -05:00
Luiz Augusto von Dentz
118dc75cea Bluetooth: GATT: Add connection to bt_gatt_notify
This allow sending direct notification to a specific peer without
using CCC which is allowed by the spec:

  BLUETOOTH SPECIFICATION Version 4.2 [Vol 3, Part F page 507
  3.4.7.1 Handle Value Notification

  A server can send a notification of an attribute’s value at any time.

Change-Id: Ieff29216cb9ba197c0da92d7b22b26e63101cfa8
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:24:37 -05:00
Mariusz Skamra
a9bda070d3 Bluetooth: Add missing break statement
Change-Id: I6950edb8dc0dcae4e96dbabd7fa66b03de7c2f92
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:24:37 -05:00
Mariusz Skamra
83fe7c7d71 Bluetooth: Add BT_ATT_MAX_LE_MTU define
This patch cleans up the code a bit. BT_ATT_MAX_LE_MTU defines
MTU that can be used over LE ATT.

Change-Id: Ie433f33f3bcba3275f51e1bea826bb0fd061c45f
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:24:37 -05:00
Mariusz Skamra
967776deed Bluetooth: GATT: Add connection authentication check
If attribute requires authentication to be read or written,
we check if current security level (should be BT_SECURITY_HIGH
or higher) allows to perform such operations on this attribute.

Change-Id: Ibba542ac96af00722370eba77d6c929cda520fd8
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:24:37 -05:00
Szymon Janc
a141da9756 Bluetooth: SMP: Use best effort for MITM in Security Request
Always set MITM in AuthReq if local IO capabilities allow it.
This match Security Request behaviour with Pairing Request.

Change-Id: I1734df6661bada296b088cc762a871c443b9e5d1
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:24:37 -05:00
Mariusz Skamra
d523f0bd66 Bluetooth: tester: Handle set discoverable command
Set discoverable command is used to set the discoverable flags
in advertisement data.

Change-Id: If46a5e05379c5f589afb1658a7b275a82c52e4e1
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:24:37 -05:00
Mariusz Skamra
e35203e863 Bluetooth: Add Limited Discoverable Flag definition
For limited discoverable mode, we need to have a define
for this advertisement flag.

Change-Id: I774b68546983697844eca2644b0ca0a85b8026e8
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:24:37 -05:00
Luiz Augusto von Dentz
d55e4ca91c Bluetooth: Add CONFIG_BLUETOOTH_L2CAP_DYNAMIC_CHANNEL
This adds an option to enable L2CAP dynamic channel support, fixed
channels are not affected by it.

Change-Id: If36bece46b7b94142ea1ac976b878d1b5ae6a578
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:24:37 -05:00
Luiz Augusto von Dentz
4a41da9b38 Bluetooth: Add l2cap-register command to btshell
l2cap-register can be used to register a server:

btshell> l2cap-register 0x0080
bt: bt_l2cap_server_register (0x0011110c): PSM 0x0080

Change-Id: I2c2d9a4cba70b0cddaf352830659d206b609ee63
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:24:37 -05:00
Luiz Augusto von Dentz
4197aa814c Bluetooth: Refactor fixed channel data
This refactorer fixed channel data so that the channel itself carries
any extra context necessary.

Change-Id: Iea0f29fb7913a29dccdcbef72d92ec4cf4711bf3
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:24:37 -05:00
Szymon Janc
6c82a63e8b Bluetooth: SMP: Use JustWorks if none side requires MITM
From Core Spec Vol 3 Part H 2.3.5.1:
"If both devices have not set the MITM option in the Authentication
Requirements Flags, then the IO capabilities shall be ignored and the Just
Works association model shall be used."

Change-Id: I450f8ab5661382b787fe9742937d47df62fb6cfa
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:24:37 -05:00
Luiz Augusto von Dentz
30b6a9fe7b Bluetooth: L2CAP: Add initial public API
This split L2CAP API so that server API is available to applications
while the rest of the API is keep internal to the stack.

Change-Id: I031926ff906ce100684fba0947b2e9eb2c8fcaeb
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:24:37 -05:00