If we are low on buffers we don't necessarily need to have
bt_buf_get() fail if we are in any other scheduling context besides an
ISR. This patch makes the bt_buf_get() function implicitly wait for
more buffers in case none are immediately available. The call to
get_wait() is done as a second step after a non-waiting call so that
we can give a warning log that the stack is running low on available
buffers.
Change-Id: I37430acc337302df23e516c07d38e08b9d61c57c
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Some logs indicate potentially problematic situations but are not
necessarily errors. Since we do want to log these regardless of the
debug setting it's better to have a separate BT_WARN macro for them.
Change-Id: Iad13fc4b58329113458c97b02855033836618f5b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
We're already sending 'dummy' buffers to wake up the connection
fibers. The problem is that if we provide a real buffer type it may
have unintended consequences. E.g. with BT_ACL_OUT when bt_buf_put()
is called it may trigger an invalid HCI_Host_Num_Completed_Packets
command.
This patch creates a new BT_DUMMY buffer type to avoid this scenario.
The new type is an alias for BT_CMD since the pool where these buffers
come from is not quota-controlled and synced up with the controller.
Change-Id: I42ac235811dc242345853f7858c10bfc43e4f07d
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Every time we put a BT_ACL_IN buffer back to the pool we should report
this to the controller so it knows it can send us more data. This
patch makes the necessary modifications to the bt_buf_put() function
to trigger the HCI command.
The Host Number of Completed Packets command is special in that it
doesn't need to obey the reported ncmd value and also doesn't generate
any command status/complete events. Because of this we need an
exception for it in the bt_hci_cmd_send() function.
Change-Id: If65f28078fd0d81af853447e95bc53822fea75b7
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
To start supporting controller to host flow control we need to tell
the controller our supported packet count & MTU and send the enabling
HCI command. This patch does the necessary addition to the HCI init
procedure.
Change-Id: I51a66f8cc3a85782a5085f9aae0f4aeb59decad3
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
To track which ACL handle each buffer belongs to (needed for host flow
control) add the necessary information into a new ACL-specific struct.
Change-Id: Ie6cc7c32a70b43a4ff5954bb9dca34e4f62da292
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
To accommodate for ACL user data move the HCI command/event data into
its own struct and put it inside a union in bt_buf.
Change-Id: I680500b15709d14b1e9f70ced88664d607a6568c
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
In case we for some reason end up in a situation where we'd send
commands while dev.sent_cmd is already set, be sure to clean it away
to avoid potential buffer leaks.
Change-Id: I0aadb84086211e245cb6c1486af885d1dbabfa14
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The APIs to send HCI commands will be needed by more than just
hci_core.c. This patch exports them through hci_core.h.
Change-Id: I7c047f070f25c9f2f8685b46bbce84c4ed459b44
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
If we get an invalid packet type here the buf pointer will be NULL.
Going to the cleanup section at the end of the function would trigger
a bt_but_put() call which would cause a NULL pointer access. Directly
returning from the function is the right thing to do instead.
Change-Id: I0c18646e0820cf829ef8aa3f77835ba0a14375b5
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The test registers Bluetooth driver to Bluetooth the subsystem and
runs bt_init() which calls open() callback. We return expected error
to indicate that there is no real Bluetooth device attached.
Change-Id: I39526acbb25e7d4bb322d4511659a40505874592
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
The test registers Bluetooth driver to the Bluetooth subsystem and
runs bt_init() which calls open() callback. We return expected error
to indicate that there is no real Bluetooth device attached.
Change-Id: I1b324c82ce8be2ce73f2b41a07135b0bc76eed61
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Now that we never have more outgoing ACL buffers in circulation than
what the controller is capable of accepting we don't need a separate
semaphore for managing the flow of ACL data to the controller.
Change-Id: I28a14791e8f46ac62b8025956c2865039eae9059
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
To ensure that we never have more outgoing ACL buffers available than
the controller is willing to accept we should hold on to them between
calling drv->send() and getting the corresponding Number of Completed
Packets event. This patch adds a temporary FIFO in bt_dev for this.
Change-Id: I918119a03081d507de2bb4a731b2709ea99a648d
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
In order to do proper flow control of ACL data to/from the controller
we need to have precise management of the available buffers. Mixing
with the events/commands buffers would make this impossible. This
patch splits the buffer pools into three separate ones:
1. HCI commands/events
2. Incoming ACL data
3. Outgoing ACL data
The total number of available buffers is also increased to match
what's the smallest number supported by current controllers (to avoid
the stack from becoming a bottle neck).
Change-Id: I7e131d61c83a4dda554068d7917c5ee09f2f837d
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
We may soon want to have a _wait() variant of bt_buf_get, so to avoid
the number of 'get' function growing too large consolidate the
existing get() and get_reserve() functions into a single one. The new
consolidated function also takes the type as input parameter so that
we know this from the very start and thereby plan for the split into
multiple buffer pools.
Change-Id: Ia09448565349def2be9bc08d9510fedd029480b4
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
We'll soon want to have dedicated pools for outgoing and incoming ACL
data. To know from which pool to get and put the buffers each buffer
should contain enough information to distinguish the two types. This
patch splits the old BT_ACL type into two new BT_ACL_IN & BT_ACL_OUT
types.
Change-Id: I7d3c05c26d2a70f80fb1229e245aa21673ec378b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The hci.h header file depends on the integer type definitions from
stdint.h and the PACK_STRUCT macro from toolchain.h. This patch adds
those so that users of hci.h don't need to be concerned of this
detail.
Change-Id: Ib1856cdec75a3bab1b86bc832cdec6ad0461db6d
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The buffer handling code is quite large and will continue to grow. As
it's not strictly HCI core material it's better to just manage it in a
separate file. This patch moves the code to include/bluetooth/buf.h
and net/bluetooth/buf.c.
Change-Id: Ie1ff79ac2cfa132359ce9f7674ff812d34b228aa
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This patch adds support for the ATT fixed channel. A dedicated att.c
file is added to handle the ATT protocol handling.
Change-Id: I2e481f56168b6f1b4c564f10d25dee0a85fb968f
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This patch adds basic L2CAP functions, including support for the LE
signaling channel as well as performing a connection parameter update
in slave (peripheral) role.
Change-Id: Ie1f9751475adcf26576e9587bf6d68d15d6a2569
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This patch adds a new bt_conn struct which abstracts the details of an
connection. Each connection has two fibers: one for incoming and
another for outgoing data. For now only one connection is supported.
The patch also adds a basic L2CAP header definition so that fragmented
ACL packets can be properly parsed.
Change-Id: Ida38b2657a0e908a18219c3aa2997eb314f2c8a1
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This patch adds a simple event handler for the LE Disconnection
Complete HCI event. An extra thing the handler needs to do is to
re-enable advertising if necessary, since it will have been implicitly
disabled by the controller upon a connection event.
Change-Id: Ie6f2eecb8c1d7de16fea24c8fd1533545f41baa5
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Several Bluetooth sub-modules will need to have access to the bt_dev
struct definition. This patch moves it to the internal hci_core.h
header file where the sub-modules can access it from.
Change-Id: Ic949c03eb5df86f60a2dac28322d029de10822b5
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This patch adds a basic event handler for the LE Connection Complete
HCI event.
Change-Id: Iea099fe1b8c87fcd00d13e8793ebce8ced7adec6
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
All LE related HCI events come wrapped in a LE Meta 'super' event.
This patch adds a basic event handler for it.
Change-Id: I4a037d4af080c3ba0f982586065c0c49b6cf7640
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
We shouldn't be sending more ACL packets to the controller than it
is capable of accepting. This patch adds a semaphore to track the
number of available controller-side ACL buffers.
Change-Id: Ib280afa06aade68eee03e44e33624eebb700dad5
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This patch adds a simple app which initializes Bluetooth and enables
connectable advertising (i.e. starts acting in the LE peripheral
role).
Change-Id: I15bb43ce657b5592d32187a0dfd22ba8bd912641
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This patch adds a simple API for enabling advertising and specifying
the friendly name in the advertising data. The API is probably not a
final one but fulfills the initial need to create apps that are able
to act in the LE peripheral role.
Change-Id: I3ff7e72ece377d872ef1b0e4ad44aeb293cc13e5
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
To manage LE advertising we need basic HCI definitions for the
commands and events involved. This patch adds those to the hci.h
header file.
Change-Id: Ic6cf17369ad09d97ca5c098f25ba786d265d0bfd
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Revises the nanokernel footprint benchmark project so that the
minimum x86 configuration explicitly excludes support for the
system timer. (This doesn't actually save any memory, since timer
support was already being excluded; however, the project now makes
this lack more apparent, and does it the same way as the minimum
microkernel benchmark project does it.)
Change-Id: I509994bb640fee3208e4c1397a79cd134172370a
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Revises the microkernel footprint benchmark project so that the
minimum x86 configuration excludes support for the system timer.
The resulting "tickless kernel" image is about 1200 bytes smaller
(about 15%).
Change-Id: Ie7be8427963818c7d0d75173d3da844722487f0b
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Revises sysgen so that it doesn't generate timer-related variables
or executable code for a tickless microkernel. Also corrects some
misleading comments about dependencies on timers.
Change-Id: I5655e32fcab22d9991f2f8e0f2db9557642b6b54
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
- Needs the same change as for nanokernel timer code to prevent
a divide by zero error.
- Eliminates a prototype version of task_sleep() that attempted
to delay by busy waiting; this won't work because the kernel
won't have any timer support in place at all!
- Removes some unnecessary #ifdefs.
Change-Id: I0debf7aed4e4075f5821a77014c3a1d65fefe923
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Only required a minor tweak to avoid a divide by zero error.
Change-Id: Id2cc680ba621f0a3df9660606e9bbfa81c6fbe46
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Revises microkernel memory pool code so that it properly handles the
case where the kernel does not have timer support.
Change-Id: I38fc3916681bbd3ac678399724ddb679a16f6ead
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Revises microkernel memory map object code so that it properly
handles the case where the kernel does not have timer support.
Change-Id: I2dfb0663c91370ffbaed94d1d6aea909f64398db
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Revises microkernel mailbox code so that it properly handles the
case where the kernel does not have timer support.
Change-Id: Ibd3ff657e0cad1320d037d7c1e3e3c673c56c9e9
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Revises microkernel FIFO code so that is properly handles the
case where the kernel does not have timer support.
Change-Id: If069cafbcf695c48c2d788ea2a6b6e04a9f0c878
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Revises microkernel semaphore (and semaphore group) code so that
it properly handles the case where the kernel does not have timer
support.
Note: Semaphore code has some commands and routines whose names
imply that they are used only in cases where a timeout occurs,
even though they can be used in non-timeout scenarios too!
Change-Id: I6747032dd215f9b98e9d7d971e4b3ff32fbd7e55
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Revises microkernel mutex code so that it properly handles the
case where the kernel does not have timer support.
Change-Id: I987780521e137b95b9544013793937cdf45abafb
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Revises microkernel task IRQ code so that it properly handles the
case where the kernel does not have timer support.
Change-Id: Idc9bd120151e5c18798e1ed98af30dabe245fe64
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Revises microkernel event code so that it properly handles the
case where the kernel does not have timer support.
Change-Id: I72b0cef0e6a8cd19206857ec6c7564edf94edb72
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Revises the relationships between several configuration options
to support a tickless kernel capabilty. Specifically:
1) SYS_CLOCK_TICKS_PER_SEC is now always defined, so that it can
be referenced by TICKLESS_KERNEL. However, SYS_CLOCK_TICKS_PER_SEC
is forced to 0 when there is no timer interrupt support.
2) NUM_TIMER_PACKETS is now forced to 0 in a microkernel system
when TICKLESS_KERNEL is enabled.
3) TIMESLICING is now disabled when TICKLESS_KERNEL is enabled.
Change-Id: Ie8bf58e7828069afe68ae9451ffbf9bc220ea35f
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Updating the micro kernel structures and variable names to create a
more meaningful context by their name.
Change-Id: Ib3ae2cd9055f0690d454a0f52488721541c0fb62
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
Updating the micro kernel structures and variable names to create a
more meaningful context by their name.
Change-Id: Ie7b14787d36d99ed131db6ac3d4fbb652dc39b57
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
As for 16 bits integers, let's add utility byteordering macros for 32
bits integers.
Change-Id: I3113b9890992e4335d300a17738e5bb772b719ae
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Converts all remaining references to the obsolete LITE symbol by
changing them to CONFIG_TICKLESS_KERNEL.
Note that the tickless kernel capability remains experimental,
as more work is required to properly support it.
Change-Id: Ie0d2514d00c3fd86297f38499e79f4d9c9edc15c
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Introduces the TICKLESS_KERNEL configuration option, which indicates
that the kernel does not support timing capabilities. This option is
enabled automatically if the system tick rate is set to zero ticks
per second.
Change-Id: I20e6eb23465baf5f79055c7ff8979537b85dcc06
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Not related to the LITE support in the kernel, that VXLITE
variable was provisioned for a potential other name for
VxMicro, and was never used.
Change-Id: I23ce1fda1064141ab7e7e75fa2b2a12b9361d624
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>