Commit graph

550 commits

Author SHA1 Message Date
Tomasz Bursztyka 23f6eb9953 drivers: ieee802154: Implement get_lqi() relevantly
Change-Id: Idc433b77ea3cb38af648d70ad285429c29e53c08
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:04 +02:00
Tomasz Bursztyka aa54086dc6 drivers: ieee802154: Fix some old left-over before multi-frag support
And take the opportunity to reduce the buffer size, as 127 is the 15.4
MTU, it has just engouh space on 128 bytes for the spi cmd plus the
frame.

Change-Id: Ifdeb83f85ab1adcdebc55bd72c38a98f18a86dbc
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:04 +02:00
Tomasz Bursztyka 9313172f84 drivers: ieee802154: Let's timeout on cc2520 tx
Looks like getting an SFD interruption is not 100% reliable, so let's
just use a semaphore with a timeout on it instead of using
device_sync* routines.

Change-Id: I4e4115c7b939c95d7e75fbb33664d411e0a6e8cc
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:02 +02:00
Tomasz Bursztyka d33c883eaf drivers: ieee802154: Rework RX buffer handling in cc2520
Flushing rxfifo is necessary only on complete failure. It's badly
documented, but cc2520 errata mention that srxflush instruction should
be avoided as much as possible because it generates garbage in rxfifo
and kills incoming rx packet.

Change-Id: I486f7f4179103cf0c86c206821a0a61fec06178a
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:02 +02:00
Tomasz Bursztyka f8ec175aa7 drivers: ieee802154: Fix length handling in uart-pipe
15.4 drivers are supposed to append LQI byte in the end of the buffer,
but of course there is no such thing in uart-pipe. Thus the bug, so
let's announce the proper length even if such LQI is missing.
Also align the debug output to proper length (FCS included)

Change-Id: Ib9ad86a8c22e1cf6437bc82e7fce11a489d0e761
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:02 +02:00
Jukka Rissanen aabd839213 net: ieee802154: MAC address needs to be stored in big endian format
The upper IP stack uses the MAC address to construct the IPv6
address in SLAAC. Because of this the MAC needs to be stored
in big-endian format so that it can be used directly as is.

Change-Id: Ib31da56307017b4284031328772d4cb51d84fa23
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:57 +02:00
Tomasz Bursztyka 11a1d9ef32 drivers: ieee802154: Make uart pipe driver tx one fragment only
Let's not count the whole buffer length but only the very first frag's.
Up to L2 radio strategy to loop on every fragments and call tx for each.
(once sent, it deletes the fragment, so next fragment is always
buf->frags).

Change-Id: I94130fedfbecffdf62286bcb7f10563c776a255e
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:55 +02:00
Tomasz Bursztyka 0f2164cb5a drivers: ieee802154: Make CC2520 ready to tx only one fragment
The given buffer can come with many fragments, but it's not up to the
hardware driver to send all of these but only the first in the list.
The overall fragments send procedure is handled in l2 level where the
radio transmission strategy loops over the list of framents and send
them one by one relevantly.

Change-Id: Ia7ae42ab4e9f8efb83bf07de6791918059b1e1c9
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:55 +02:00
Tomasz Bursztyka 1cd4190b2f drivers: ieee802154: cc2520: do not recalibrate rx after tx
As we use STXONCCA, RX will be stopped and reinstated afterwards.
We would be using STXON, since FRMCTRL1_SET_RXENMASK_ON_TX bit is set,
behavior would be the same.

Recalibrating the RX will uselessly abort any received frames before TX
or right after RX got reinstated. So, let's not do that and trust that
RX is anyway properly calibrated after TX.

Change-Id: Iac4fa03a175f8d139c1fc821de01caab1ec86e6b
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:55 +02:00
Andrei Emeltchenko 68e7037104 ieee802154: Correct error logging for cc2520 driver
Change DBG to ERR for error cases to get errors when only errors are
selected.

Change-Id: I51fd15900b1efb96d5dff36367afcdf380f11b88
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-12-02 12:40:52 +02:00
Andrei Emeltchenko daefa3d979 ieee802154: Add log domain for CC2520 driver
This prepends logs instead of [general] with [cc2520].

Change-Id: I148159a451981fbe3da638732f0e97900f76bc58
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-12-02 12:40:52 +02:00
Tomasz Bursztyka 18601fedb0 drivers: cc2520: Fix LQI computation and generalize it
LQI is actually not provided as is, but should be computed from an
abstract correlation factor. See Section 20.6.

LQI is provided the same way as Linux does, so it can push it everytime
into the buffer.

Change-Id: I5de318db2c2581d7482cc16e41dc601130753a62
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:47 +02:00
Tomasz Bursztyka cf9dcd3d5b drivers: cc2520: Fix 80 chars lenght limit
Fixing 80 chars limit by removing length computation:
We can count the FCS as part of the received length, even if AUTOCRC is
on. L2 layer is able to parse this out.

Change-Id: I3c824ed95d177570a07d04784798e14f5979c96b
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:47 +02:00
Andrei Emeltchenko b41457bc5a ieee802154_cc2520: Fix compiler warning with strict aliasing
Fixes compiler warning with strict-aliasing rules shown below.

 ...
CC drivers/ieee802154/ieee802154_cc2520.o
drivers/ieee802154/ieee802154_cc2520.c: In function 'get_mac':
drivers/ieee802154/ieee802154_cc2520.c:290:42: warning: dereferencing
type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
...

Change-Id: Idb0522e4d2207932c9335db1ca12961a5093b48c
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-12-02 12:40:46 +02:00
Andrei Emeltchenko 7889ebaf5e net: Add L2 RAW channel hidden option
L2 RAW channel allows to use some functions of IP stack for RAW access
of network drivers. It is hidden from user and is selected by 2520 raw
driver.

Change-Id: I91dd09803052072dfddb7989d9d67c3a5840f89e
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-12-02 12:40:46 +02:00
Andrei Emeltchenko ca2cc81d7a net: Add TI_CC2520 RAW driver
Add TI CC2520 driver allowing RAW access to radio interface similar
way Bluetooth user channel works. This makes possible to handle radio
channel inside external 802.15.4 stacks, for example export it over USB
and handle in Linux.

Change-Id: I61bb4c8b998ff1e47dc65427ac471f04ec8fea63
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-12-02 12:40:46 +02:00
Andrei Emeltchenko d6155e0cf9 ieee802154_cc2520: Correct debug output
Change-Id: I52979eb6661aac62eea875f088972d472f46ef81
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-12-02 12:40:45 +02:00
Andrei Emeltchenko b85b27eab2 net: Do not source contiki headers always
Source contiki headers only for legacy driver

Change-Id: I356fd65ce9a4ee144c29eed1b51f2f0175315c1c
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-12-02 12:40:45 +02:00
Andrei Emeltchenko b2a478b935 net: cc2520: Fix setting proper IEEE 802.15.4 address
The bug was introduced by commit ID
a136a2587752cca256950b0efd5567ca29117d11

Which led to write junk as an address into cc2520 and thus made the
chip filtering out all unicast packet (as the incoming address never
matched)

Change-Id: I72009e795039f2059177a5b37a4bcf5d9717d65d
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-12-02 12:40:45 +02:00
Tomasz Bursztyka 4b7309c751 net: cc2520: Let's provide ll addr in LE already
As it used directly as the ieee addr.

Propre endianess will have to be solved once this stack will be ported
to other arch than x86.

Change-Id: Ie556fabbd99cc5559025c8392d2f699facb007fa
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:28 +02:00
Tomasz Bursztyka 6790484ce2 net: ieee802154: Auto ACK and CRC are always on
We have no use of configuring cc2520, at built time at least, in
promiscuous mode. So let's get rid of these options for the new driver.

Change-Id: I17611c43bc7ba7961831beaa47cc4e2371f8de61
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:27 +02:00
Andrei Emeltchenko 29e3bcfcde ieee802154_cc2520: Fix byte order swap for long address
This fixes bug setting incorrect long ieee802154 address and also
print address in BE byte order the same way as for Linux.

Change-Id: I774301e992372588dffa6ce5964fb119642a0a0d
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-12-02 12:40:26 +02:00
Tomasz Bursztyka fc0e6497af net: drivers: Add a fake ieee802154 radio driver for qemu
This driver is used for testing on Qemu where all "radio transmission"
will go through a pipe between 2 Qemus.

Change-Id: I5b4e75de82a98eb730ef9c70b460b4b60c0a60c3
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:24 +02:00
Tomasz Bursztyka 6b0732f632 net: drivers: Normalize ieee802154 Kconfig
Indent with tabs, no spaces.

Change-Id: Idee4167039964c253cf280cced787b05873f2780
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:24 +02:00
Tomasz Bursztyka 73d8c7c443 net: drivers: cc2520 ieee802154 drivers select relevant options
If no IP stack is seleceted, selecting one of the 2 cc2520 driver will
automatically select the relevant stack.

Change-Id: Icca22da190dc790ce6d302e14c45732f902e02ae
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:24 +02:00
Tomasz Bursztyka b283640f10 net: drivers: ieee802154: sys_log is needed on legacy driver
Or the build will not go through.

Change-Id: I48f5f8661c4100a76e4624ea64d383055327e2a7
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:23 +02:00
Tomasz Bursztyka 3e0c1ff876 drivers: cc2520: Raise Rx stack size
640 bytes seems too short, raising to 800 bytes.

Change-Id: I8c3418787939369e24fe47c23b0558c36f05af2c
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:22 +02:00
Tomasz Bursztyka 434ba9311c net: ieee802154: Logging header should be loaded first
net_core.h is loading sys_log.h as well, so we need to be
first in order to setup some local definitions.

Change-Id: Ife482bd21e314aa5a5e88433eb8f9a560f9d53a6
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:21 +02:00
Tomasz Bursztyka 4c0d9bcf9a drivers: cc2520: Add a new IP stack ready adaptation of CC2520 driver
It's basically a copy/paste of original driver,
using native IP stack API.

This is meant to avoid cluttering the original driver
code with #ifdef, and in future it will help removing
the old driver as well.

Change-Id: I67d974ad7440d258583a5c7c6c7160e99210808c
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:18 +02:00
Tomasz Bursztyka ed6ad65427 drivers: cc2520: Make current driver for legacy stack only
Another driver will be made for native IP stack. This is meant
to avoid cluttering the code with #ifdef all over the place.
Instead driver will be transparently selected at built time.

Change-Id: I283f1194fece9357425b87794b5cb51938ca80d3
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:18 +02:00
Baohong Liu b58b1bbc9c drivers: cc2520: fix variable type mismatching issue
The variable type mismatching was caught by LLVM.

Jira: ZEP-1179

Change-Id: If26c881d207a6cedc52b7589c5d7ebb2040c7ab7
Signed-off-by: Baohong Liu <baohong.liu@intel.com>
2016-11-18 00:21:32 +00:00
Andrew Boie 6450aa455c ieee802154_cc2520: use new kernel sleep APIs
Change-Id: Ia1831108d2f57f76244c9d0a35c47308373aaa1c
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-11-07 11:34:15 -08:00
Andrew Boie a6463a93c1 drivers: ieee802154_cc2520: fix unified build
In the unified kernel legacy layer, both these functions are
implemented as #defines which can't be put in a struct.

Eventually this driver should be updated to use new APIs, but
this will get it to at least build which is the priority.

Change-Id: Ic5dfb5b85ff3bd0d1646f542340642549a2b2e05
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-11-02 00:00:29 +00:00
Marcus Shawcroft a7c5ec1150 ieee802154: Limit name space, add static.
Change-Id: Iaf33a902b90a649ebe8591c33798ad4e583ee33a
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-10-26 20:51:02 +00:00
Tomasz Bursztyka cc54803d9e drivers: ieee802154: Fix register name
It's not FMSTAT<0/1> but FSMSTAT<0/1>

Change-Id: I836cf001b7baefe86df67f13a8759ea4e697a28e
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-10-21 17:03:57 +00:00
Anas Nashif 78ce02f86d quark_se_devboard: We do not support capabilities via Kconfig yet
This will lead to conflicts and warning coming from Kconfig, so just
whitelist the board in the samples where this hardware is supported

Jira: ZEP-739

Change-Id: I4a2f3bdcfdb44fc75df0e272c237789ee16e0de1
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-08-25 06:12:00 -04:00
Jaakko Hannikainen db493450ac net: ip: Fix compiling with 15.4
Kconfig allows selecting NETWORKING_WITH_15_4_TI_CC2520 even if the
current board doesn't support it, and also selects it by default. This
breaks building the 15.4 sample with qemu_x86. Add a config option for
having CC2520 support and enable the choise only if it is available.

In addition, remove unused function from iee802154 code, as it now
fails the tests.

Jira: ZEP-697

Change-Id: Ib082f82acdd0f86d3306bbd3bb827f61b0fd0be1
Signed-off-by: Jaakko Hannikainen <jaakko.hannikainen@intel.com>
2016-08-23 13:13:59 +00:00
Genaro Saucedo Tejada 67c465d2cc sys_log: replace old debug macros at ieee802154 driver
ieee802154 driver is now using new system log macros, update the
Kconfig variable to be a level rather than a bool and the .conf
files at samples.

JIRA: ZEP-311

Change-Id: I640e973d880c3a222cd7c13a72d35edf49ada3a8
Signed-off-by: Genaro Saucedo Tejada <genaro.saucedo.tejada@intel.com>
2016-08-01 22:03:45 +00:00
Tomasz Bursztyka bf40601c2a cc2520: Fix how FREGs and SREGs are accessed
- SREGs should use MEMRG/MEMWR instructions, FREGs use REGRD/REGWR
- REGRD/REGWR get the register address in the first byte along the
  instruction.

Reported-by: Igor Modino <igor@emutex.com>

Change-Id: I0da9de5ecd4cab914c8711bd4276e7a2bc6147a5
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-06-22 04:47:43 +00:00
Kumar Gala 9ec2f3be80 Cleanup whitespace in Kconfig files
Convert leading whitespace into tabs in Kconfig files.  Also replaced
double spaces between config and <prompt>.

Change-Id: I341c718ecf4143529b477c239bbde88e18f37062
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2016-05-25 13:28:07 -05:00
Tomasz Bursztyka 7cd63abccb ieee802154: cc2520: SPI workaround when QMSI drivers are in use
Current QMSI SPI API does not handle asymmetric tx/rx buffers, and thus
it's up to cc2520 driver to manage the tx dummy bytes.

Change-Id: I97900946bcd8d96e9f039646bccd765c574c363e
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-05-04 13:47:17 +00:00
Tomasz Bursztyka 6fc7566cdd ieee802154: cc2520: Invalid argument should return -EINVAL
-EIO is an error code for operationnal error, not about invalid
argument.

Change-Id: I7064eaf01c6040d2e93ed43df3932d8baed1256e
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-04-27 14:49:41 +02:00
Andre Guedes 04cdf8b6e8 ieee802154: Fix returning codes
DEV_* error codes are deprecated and should not be used anymore. This
patch replaces DEV_* occurrences by the corresponding errno.h code,
according to the error code conventions.

Change-Id: I7b098a6107c390b46ed15aaeb9141627e9502727
Signed-off-by: Andre Guedes <andre.guedes@intel.com>
2016-04-26 22:49:48 +00:00
Tomasz Bursztyka 51503a2388 cc2520: Using new GPIO API callbacks
Adapting CC2520 driver to use the new callback format. That way, cc2520
will work on boards where FIFOP and SFD are hooked to a different GPIO
controller.

Change-Id: Ia40b17867000de26f332f36422f84bb3f20be2aa
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-04-22 22:17:53 -04:00
Tomasz Bursztyka c239a8cb7b cc2520: Properly start and stop the device
Disable reception and the oscillator as well when stopping. Revert
when starting.

Change-Id: I2a61066602267ac61e691ec9c20eb243de6fa076
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-04-14 07:49:23 +00:00
Tomasz Bursztyka d8dcf56334 cc2520: Enable hardware filtering all the time
This prevents false packets to get accepted/generated into RX fifo.
Also, this will make AUTOACK working properly, when enabled. For some
reasons FRMFILT1 and SRCMATCH need to get their reset values written at
initialization, or then hw filtering won't work. This behavior is not
documented as it seems.

Change-Id: Ic0fe664dbc3b17d85d794c12b77bdbaafeb601f5
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-04-14 07:49:23 +00:00
Tomasz Bursztyka a9af3c0512 cc2520: Set short address and ieee address from the driver
For hw filtering and autoack to work, all the information should be
properly set in the chip.

That's a fix for the legacy radio/net API. From original code, these
were set from the application which is bad. But setting it from the
driver is not any better. ieee802154 and net stack should know what to
do, that will be fixed in the future.

Change-Id: I1688223e9488d10a423e788eb88ba1e251cb3f88
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-04-14 07:49:23 +00:00
Jukka Rissanen 12485eb8c9 cc2520: Make the generated MAC address to look more random
Because the random number generator is very dumb at the moment,
the generated MAC address has always last byte set to 0.
The MAC address is used when generating IPv6 address.
In order to avoid IPv6 address collision, swap the last four
bytes of the MAC address so that the most random data is
at the end of the MAC.

Change-Id: I96c03654359e32f407bab3b29be0e3b08ee91bd7
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-04-12 16:27:21 +03:00
Tomasz Bursztyka a1adbcb125 ieee802154: Replace the CC2520 driver with a new implementation
This is a complete new cc2520 driver for zephyr. Intention is to fit
better within Zephyr device driver model.

- It's (almost*) ready to be instanciated as many times as necessary
- It's fully interrupt based on SFD and FIFOP (no pin polling)
- It's nicer to other sub-systems (it sleeps, no busy-wait loop)
- It still loosely complies to old legacy radio device driver model

*: GPIO API needs to be fixed in order to accept multiple callbacks, as
well as enabling callbacks to retrieve private data.

Notes:
- Hardware filtering does not work yet as the net stack, above, needs to
  provide the relevant information for it (src/dst ieee802154 extended
  addresses, short addresses...)
- A embryo of generic functions (txpower, channel, addresses...)
  have been implemented but don't belong yet to any radio device driver
  model. Such new driver model will come afterwards (soon?)
- SPI API would need to be improved to avoid as much as possible memcpy
  as well as spi_slave_select() call.

Change-Id: I1fd6dfff28fba3984f6006d394ea12f1e763ac18
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-04-07 17:25:02 +00:00
Tomasz Bursztyka f7d5d2c8f5 drivers: Renaming directory "802.15.4" into "ieee802154"
ieee802154 is a more relevant name. Applying the change in
include/drivers as well.

Change-Id: I7f7188ed0421045d7667303c375eeb8af1298b97
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-04-07 17:24:55 +00:00