Commit graph

943 commits

Author SHA1 Message Date
Jukka Rissanen d8defbd08a net: bt: Convert network Bluetooth shell to use new shell
Use new shell instead of the legacy one.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-10-15 11:14:02 +03:00
Jukka Rissanen 1f4bae79e2 net: ieee802154: Convert IEEE 802.15.4 shell to use new shell
Use new shell instead of the legacy one.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-10-15 11:14:02 +03:00
Jukka Rissanen 681ff12379 net: wifi: Convert wifi shell to use new shell
Use new shell instead of the legacy one.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-10-15 11:14:02 +03:00
Jukka Rissanen fa8ff4f379 net: arp: Add support for receiving gratuitous ARP request
If we receive a valid gratuitous ARP request, then update ARP
cache accordingly. This feature is optional and by default
it is enabled, but can be turned off if needed.

This is similar to a feature available in Linux, and is enabled
by default in many distros.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-10-10 16:12:35 +03:00
Dong Xiang 026f06efeb net: l2: update wifi mgmt to adapt non-offload wifi chip.
The wifi mgmt does only support TCP/IP offload wifi chip,
while non-offload wifi chip can not scan/connect to AP.

Signed-off-by: Dong Xiang <dong.xiang@unisoc.com>
2018-10-10 11:38:04 +03:00
Jukka Rissanen 7138e34d31 net: wifi: Removing SYS_LOG_DBG as that is no longer used
The wifi management interface was still using one SYS_LOG_DBG
macro call, replacing that with NET_DBG.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-10-05 10:08:32 -04:00
Jukka Rissanen 57a8db7789 net: Use log_strdup() when printing debug strings
As the debugging print calls are async, all the strings that might
be overwritten must use log_strdup() which will create a copy
of the printable string.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-10-04 14:13:57 +03:00
Jukka Rissanen 15e7e3ea4b net: ip: Split debug prints into smaller pieces
Currently logging subsystem supports quite small number of function
parameters. So split some long functions into smaller pieces.
Hopefully this is just a temporary patch and we can support more
parameters to logging macros.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-10-04 14:13:57 +03:00
Jukka Rissanen a76814bfb6 net: Convert core IP stack to use log levels
Instead of one global log level option and one on/off boolean
config option / module, this commit creates one log level option
for each module. This simplifies the logging as it is now possible
to enable different level of debugging output for each network
module individually.

The commit also converts the code to use the new logger
instead of the old sys_log.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-10-04 14:13:57 +03:00
Tomasz Gorochowik 3a51c8d932 net: gptp: Fix sync interval timeout timer starting
The last parameter is 'period', we should not pass duration twice.
Doing so makes zephyr hang with current mainline when it is chosen to be
the Grand Master.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-10-01 14:48:53 +03:00
Tomasz Gorochowik a979841ec4 net: gptp: Fix sync receipt timeout timer starting
Completely remove the last_sync_receipt_timeout time. It is not part of
the standard (see 802.1AS-2011, 10.2.11 for the complete list of
variables for this state machine). Additionally this extra variable was
never really initialized so the calculated duration made no sense.

Just start the timer based on the regular sync receipt timeout time
interval from the port data set.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-10-01 14:48:53 +03:00
Tomasz Gorochowik 0888da4dfe net: gptp: Add clock accuracy selection
This commits adds a possibility to select PTP clock accuracy through
KConfig.

The chosen accuracy should reflect the capabilities of the used
hardware.

See IEEE 1588-2008, chapter 7.6.2.5 for more details.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-10-01 14:48:53 +03:00
Tomasz Gorochowik 68127a3100 net: gptp: Initial GrandMaster capability support
Implements GMCAP-1, GMCAP-2, and GMCAP-3 and their dependencies from
802.1AS-2011. See Annex A.10 for more details.

The Grand Master Capability can be turned on and off through KConfig.

Note: the correction field in FUP packets is not yet properly
calculated. There is a TODO left in the code, near which some parameters
are zeroed to make the correction field be set to 0. This mimics the
behavior of openAvnu (a Linux gPTP client). For full compliance the
field should be calculated and set properly.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-10-01 14:48:53 +03:00
Tomasz Gorochowik 117b9ac3e9 net: gptp: Use packed enums when applicable
Optimize memory usage of enums that are used within structs.
Reorganize the affected structs to avoid holes.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-10-01 14:48:53 +03:00
Tomasz Gorochowik 5c5a4461a4 net: gptp: Fix port number in SYN and FUP packets
Make sure the packets contain the port number they are actually coming
from.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-10-01 14:48:53 +03:00
Tomasz Gorochowik 792dfd4a04 net: gptp: Convert SyncReceiptTime to ExtendedTimestamp
SyncReceiptTime should use an ExtendedTimestamp (with fractional
nanoseconds precision). Add a struct with the definition of the needed
type and convert that variable.

The struct representing the ExtendedTimestamp is named
net_ptp_extended_time to keep consistency with the existing net_ptp_time
which is used for regular PTP timestamps.

See 802.1AS-2011 chapters 10.2.3.4 and 6.3.3.5 for more reference.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-10-01 14:48:53 +03:00
Tomasz Gorochowik a84e60b8de net: gptp: Rename the ClockMasterSyncReceive state struct
There are other ClockMasterSync state-machines (to be implemented).
Current name would either cause conflicts or be too ambiguous.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-10-01 14:48:53 +03:00
Mark Ruvald Pedersen d67096da05 portability: Avoid void* arithmetics which is a GNU extension
Under GNU C, sizeof(void) = 1. This commit merely makes it explicit u8.

Pointer arithmetics over void types is:
 * A GNU C extension
 * Not supported by Clang
 * Illegal across all ISO C standards

See also: https://gcc.gnu.org/onlinedocs/gcc/Pointer-Arith.html

Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
2018-09-28 07:57:28 +05:30
Luiz Augusto von Dentz 3151d26572 Bluetooth: L2CAP: Add return to recv
This adds a int return to recv callback which can be used to notify the
stack about errors when receiving a packet. In addition to that the user
can return -EINPROGRESS to inform the stack the data will be processed
asynchronously which can be complete by calling
bt_l2cap_chan_recv_complete.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2018-09-24 12:51:11 +03:00
Krzysztof Chruscinski 527256501f shell: Rename shell to legacy_shell
New shell implementation is on the way. For now old one and all
references are kept to be gradually replaced by new shell.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2018-09-19 09:30:29 -04:00
Tomasz Gorochowik 24a91afa38 net: gptp: Remove unused macro
Minor cleanup.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-09-19 09:54:29 +03:00
Tomasz Gorochowik 3c68a06743 net: gptp: Fix the default value of sync receipt timeout
The default value shall be 3.

See 802.1AS-2011, 10.6.3.1 for reference.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-09-19 09:54:29 +03:00
Tomasz Gorochowik c3baa22778 net: gptp: Fix sync timeout calculation
Sync timeouts were calculated incorrectly - this led to a 'Multiple
Masters Issue' as denoted by PTP debugging software.

See 802.1AS-2011, chapter 10.2.4.2 for reference.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-09-19 09:54:29 +03:00
Tomasz Gorochowik 09b6f956d4 net: gptp: kconfig: Fix log-based intervals help
Fix the formula listed in help messages which is used to calculate
actual intervals given their log2 values.

It is all calculated properly in the code, because the unit of the
actual field uses the UScaledNs type of which the unit is 2^(-16)ns, so
it is just the help messages that got it wrong.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-09-19 09:54:29 +03:00
Flavio Ceolin da49f2e440 coccicnelle: Ignore return of memset
The return of memset is never checked. This patch explicitly ignore
the return to avoid MISRA-C violations.

The only directory excluded directory was ext/* since it contains
only imported code.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2018-09-14 16:55:37 -04:00
Tomasz Bursztyka b6468999e4 net/pkt: Rename link layer address accessors relevantly
*_ll_src/*_ll_dst/*_ll_swap/*_ll_if were not self explanatory, ll
meaning "link layer" it's ambiguous what the names meant.
Changing to:
*_lladdr_src/*_lladdr_dst/*_lladdr_swap/*_lladdr_if to fix this.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-09-11 16:06:13 +03:00
Andrei Emeltchenko e1757277ae net: lldp: Implement LLDP RX API
Add RX API to LLDP. Caller should register callback which is called
from ethernet_recv().

Fixes #9407

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-09-11 10:55:01 +03:00
Jukka Rissanen 42a23e2b83 net: gptp: Set stack size correctly for handler thread
The gptp stack size was not properly set, one must use
the K_THREAD_STACK_SIZEOF() macro to calculate stack size.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-09-06 09:56:51 -04:00
David B. Kinder 1c29bff055 doc: fix kconfig misspellings
Fix misspellings in kconfig files missed during regular reviews

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-08-28 13:58:46 -04:00
Paul Sokolovsky 49732b27d9 net: Move CONFIG_NET_OFFLOAD definition to net/ip/
CONFIG_NET_OFFLOAD was defined in Kconfig of net/ip/l2/, but actually
used by the code in net/ip/.

Fixes: #8646

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-08-22 12:56:34 +03:00
Jukka Rissanen a5f7e3345b net: lldp: Fix timeout triggering if multiple workers
The code was not working properly if there was multiple timers
that were triggered in different times.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-08-17 17:49:53 +03:00
Oleg Zhurakivskyy 99dc5aef88 net: ip: Refactor usage of net_sprint_ip*()
Refactor usage of net_sprint_ip*() where multiple
invocations are needed per single log call.

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2018-08-17 12:36:50 +03:00
Flavio Ceolin 0866d18d03 irq: Fix irq_lock api usage
irq_lock returns an unsigned int, though, several places was using
signed int. This commit fix this behaviour.

In order to avoid this error happens again, a coccinelle script was
added and can be used to check violations.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2018-08-16 19:47:41 -07:00
Jukka Rissanen 4078e46e7d net: l2/lib: Always have a timeout when allocating a net_buf
Instead of waiting forever for a network buffer, have a timeout
when allocating net_buf. This way we cannot left hanging for a
long time waiting for a buffer and possibly deadlock the system.
This commit adds checks to L2 and network support libraries.

Fixes #7571

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-08-14 12:17:00 +03:00
Oleg Zhurakivskyy ac92a01f5a net: ipv6: Refactor IPv6 header length handling
Change the length to uint16_t and work with it
through standard htons/ntohs() macros.

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2018-08-13 13:53:14 +03:00
Ulf Magnusson ec3eff57e0 Kconfig: Use the first default with a satisfied condition
Up until now, Zephyr has patched Kconfig to use the last 'default' with
a satisfied condition, instead of the first one. I'm not sure why the
patch was added (it predates Kconfiglib), but I suspect it's related to
Kconfig.defconfig files.

There are at least three problems with the patch:

  1. It's inconsistent with how Kconfig works in other projects, which
     might confuse newcomers.

  2. Due to oversights, earlier 'range' properties are still preferred,
     as well as earlier 'default' properties on choices.

     In addition to being inconsistent, this makes it impossible to
     override 'range' properties and choice 'default' properties if the
     base definition of the symbol/choice already has 'range'/'default'
     properties.

     I've seen errors caused by the inconsistency, and I suspect there
     are more.

  3. A fork of Kconfiglib that adds the patch needs to be maintained.

Get rid of the patch and go back to standard Kconfig behavior, as
follows:

  1. Include the Kconfig.defconfig files first instead of last in
     Kconfig.zephyr.

  2. Include boards/Kconfig and arch/<arch>/Kconfig first instead of
     last in arch/Kconfig.

  3. Include arch/<arch>/soc/*/Kconfig first instead of last in
     arch/<arch>/Kconfig.

  4. Swap a few other 'source's to preserve behavior for some scattered
     symbols with multiple definitions.

     Swap 'source's in some no-op cases too, where it might match the
     intent.

  5. Reverse the defaults on symbol definitions that have more than one
     default.

     Skip defaults that are mutually exclusive, e.g. where each default
     has an 'if <some board>' condition. They are already safe.

  6. Remove the prefer-later-defaults patch from Kconfiglib.

Testing was done with a Python script that lists all Kconfig
symbols/choices with multiple defaults, along with a whitelist of fixed
symbols. The script also verifies that there are no "unreachable"
defaults hidden by defaults without conditions

As an additional test, zephyr/.config was generated before and after the
change for several samples and checked to be identical (after sorting).

This commit includes some default-related cleanups as well:

  - Simplify some symbol definitions, e.g. where a default has 'if FOO'
    when the symbol already has 'depends on FOO'.

  - Remove some redundant 'default ""' for string symbols. This is the
    implicit default.

Piggyback fixes for swapped ranges on BT_L2CAP_RX_MTU and
BT_L2CAP_TX_MTU (caused by confusing inconsistency).

Piggyback some fixes for style nits too, e.g. unindented help texts.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-10 12:38:28 -07:00
Jukka Rissanen 31f89b0303 net: eth: Add start and stop L2 functions
If the driver has created start() and stop() functions, then those
are called when ethernet L2 is enabled or disabled.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-08-10 12:36:19 +03:00
Oleg Zhurakivskyy fbac80bb94 net: ipv4: Refactor IPv4 header length handling
Change the length to uint16_t and work with it
through standard htons/ntohs() macros.

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2018-08-09 16:25:17 +03:00
Jukka Rissanen d003d0e6a6 net: ipv4: Corrupted ARP pkt was sent instead of real IPv4 pkt
The ethernet sending routine sent a corrupted ARP packet instead
of the actual IPv4 packet.

Fixes #9348

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-08-09 11:56:44 +03:00
Jukka Rissanen 1f855095b4 net: l2: Add promiscuous mode to L2 flags when applicable
This allows more bearers than just ethernet to have promiscuous
mode support.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-08-08 11:02:30 +03:00
Jukka Rissanen 66244a0e67 net: if: No need to always join solicit node mcast group
For example for Bluetooth IPSP, it is not needed to join solicited
node multicast group address.

From https://tools.ietf.org/html/rfc7668#section-3.2.2 :

"""
There is no need for 6LN to join the solicited-node multicast address,
since 6LBR will know device addresses and hence link-local addresses
of all connected 6LNs.
"""

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-08-08 11:02:30 +03:00
Jukka Rissanen ccfcdabaf6 net: l2: Add flags to tell if L2 supports multicast
If multicast is not supported, then we do not need to join
multicast group.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-08-08 11:02:30 +03:00
Jesus Sanchez-Palencia 598276262c net: l2: Add support for Link Layer Discovery Protocol (LLDP)
The LLDP protocol defines 2 separate agents, the Transmitters and
the Receivers. For the context of Zephyr, we are only interested in
the Tx agent, thus we drop any LLDP frames received by Zephyr.

LLDP frames are basically composed by an ethernet header followed by
the LLDP Protocol Data Unit (LLDPDU). The LLDPDU is composed by several
TLVs, some of them being mandatory and some optional.

Our approach here is having TLVs fully configured from Kconfig, thus
having the entire LLDPDU constructed on build time.

The commit adds NET_ETH_PTYPE_LLDP definition and related handling.

If CONFIG_NET_LLDP is enabled then ethernet_context has a pointer to
the struct net_lldpdu that belongs to that ethernet interface. Also
when CONFIG_NET_LLDP is enabled, the LLDP state machine will start to
send packets when network interface is coming up.

Currently the LLDP state machine is just a k_delayed_work() sending the
LLDPDU at a given period (defined by CONFIG_NET_LLDP_TX_INTERVAL).

Fixes #3233

Signed-off-by: Jesus Sanchez-Palencia <jesus.sanchez-palencia@intel.com>
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-08-08 09:53:24 +03:00
Tomasz Gorochowik b6852e5a3a net: eth: mgmt: Add remaining 802.1Qav parameter types
This are all the parameters defined by the standard (12.21.1).

Additionally the parameters that are read-only are validated in the
ethernet_set_config callback.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-08-06 10:37:09 +03:00
Jukka Rissanen bab35512f8 net: ipv4_autoconf: Fix requested IPv4 address in ARP packet
Unspecified address 0.0.0.0 was used as a requested IPv4 address
because the ARP message was generated second time. So for IPv4
autoconf ARP message, generate the message only once.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-08-02 12:42:52 +03:00
Tomasz Gorochowik 805e2f2c79 net: eth: mgmt: Merge 802.1Qav related mgmt requests
There are too many individual requests for Qav related parameters. There
are more Qav parameters that need to be supported (and will be supported
soon - both on the GET and SET side). Handling it the way it was handled
so far would render the eth mgmt API dominated by Qav parameters. That
would make the file hard to read and understand.

Instead of that - use a single GET and SET requests for all Qav
parameters. This works by adding a separate enum with Qav request type
to the ethernet_qav_param struct.

Additionally this approach makes it much easier to document it all since
we now have just a single request and documentation comments in the
ethernet_qav_param struct.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-08-01 15:58:05 +03:00
Tomasz Gorochowik f568be48d0 net: eth: mgmt: Add Qav status hooks
Add calls responsible for getting and setting on/off status of Qav on
capable priority queues.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-07-31 17:54:24 +03:00
Jukka Rissanen 00e37cbb5b net: IPv4 link local support
Add basic IPv4 Link Local support as described in RFC 3927.

Signed-off-by: Matthias Boesl <matthias.boesl@gmail.com>
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-07-31 16:34:28 +03:00
Robert Lubos 80e828b983 net: openthread: Don't regsiter mcast addresses in Zephyr multiple times
OpenThread L2 could've called multicast address registration multiple
times for specific address, which resulted in having multiple entries
containing the same multicast IPv6 address in Zephyr.
Checking if address was already registered prevents that.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2018-07-31 11:13:04 +03:00
Robert Lubos 96e794e6b7 net: openthread: Register OT unicast adresses in Zephyr
Register all OpenThread unicast adresses in Zephyr, not only multicast
adresses.

Fixes #9160

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2018-07-31 11:13:04 +03:00
Jukka Rissanen 21a27e8807 net: l2: Move individual L2 to dedicated directories
No need to keep technologies in main L2 directory so for consistency
create a directory for each of them and place each L2 component to
relevant L2 directory.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-07-30 09:02:02 -04:00
Jukka Rissanen 9ffab9e63a net: arp: Fix ARP message sending if VLAN is enabled
VLAN tags were not set properly for ARP messages.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-07-30 12:47:02 +03:00
Tomasz Gorochowik 3cd1425b58 net: eth: mgmt: Extend the management interface with a getter
This makes use of the get_config callback added to the Ethernet API.

For now the only parameter to get is the number of available priority
queues.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-07-27 20:27:59 +03:00
Tomasz Bursztyka 9c5725a69d net/ethernet: Pre-assigned declaration always comes first
And no need of extra parenthesis for casting.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-07-26 13:55:38 +03:00
Tomasz Bursztyka 5ebc86bdc6 net/ethernet: A device driver api uses struct device *dev
Always use struct device *dev as first parameter for a device driver
API.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-07-26 13:55:38 +03:00
Jukka Rissanen 9b8c83f44a net: Avoid holes in structs
Move struct members around in networking code so that we avoid
unnecessary holes inside structs. No functionality changes by
this commit.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-07-25 15:20:34 +03:00
Jukka Rissanen bf9bae58d1 net: eth: Add generic promiscuous mode support
Allow ethernet L2 driver to set / unset the device driver
promiscuous mode flag.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-07-24 15:12:37 +03:00
Jukka Rissanen 408a580644 net: ethernet: mgmt: Fix Qav deltaBandwith check
As the value type is unsigned int, it cannot be <0.

Coverity-CID: 187063
Fixes #9002

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-07-20 00:02:01 -04:00
Jukka Rissanen dfa3f10b26 net: gptp: Add comment for falling through case
Make sure that it is clear that we are suppose to fall through
a case statement.

Coverity-CID: 187078
Fixes #8989

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-07-20 00:02:01 -04:00
Jukka Rissanen 27fef49d17 net: gptp: Check overflow of log msg interval
Make sure that we do not overflow when creating UScaledNS
value for interval.

Coverity-CID: 187079
Fixes #8988

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-07-20 00:02:01 -04:00
Jukka Rissanen 4670214c26 net: gptp: Fix unsigned value comparison
The nanosecond check was using <0 for unsigned value.

Coverity-CID: 187080
Fixes #8987

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-07-20 00:02:01 -04:00
Jonathan Yong 40f743669b net: eth: Convert to use callbacks to query stats
The advantage to this approach allows drivers for
devices that already keep statistics data on hardware
registers to use those instead, rather than try to
replicate it the same counters again within the driver
itself.

The eth_native_posix.c driver though do not benefit
from this, is modified to use the new callback system.

Suggested-by: Jukka Rissanen <jukka.rissanen@intel.com>
Signed-off-by: Jonathan Yong <jonathan.yong@intel.com>
2018-07-19 13:46:13 +03:00
Ramon Ribeiro 0e626f5ef5 net: openthread: Add NETWORKNAME and XPANID config
This patch add the option to the user sets the network name and
the extended PAN ID

Signed-off-by: Ramon Ribeiro <rhpr@cesar.org.br>
2018-07-17 16:40:53 +03:00
Ulf Magnusson 1073882998 subsys: kconfig: Remove 'default n' properties and clean up a bit
Bool symbols implicitly default to 'n'.

A 'default n' can make sense e.g. in a Kconfig.defconfig file, if you
want to override a 'default y' on the base definition of the symbol. It
isn't used like that on any of these symbols though.

Remove some 'default ""' properties on string symbols too.

Also make definitions more consistent by converting some

  config FOO
  	<type>
  	prompt "foo"

definitions to a shorter form:

  config FOO
  	<type> "foo"

This shorthand works for int/hex/string symbols too, not just for bool
symbols.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-07-12 23:13:22 -04:00
Jukka Rissanen 37125781aa net: gptp: Fix debug prints and use correct modifier
Use %zd instead of %lu when printing size_t variables.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-07-05 13:08:04 +03:00
Tomasz Gorochowik 226fa97304 net: ethernet: Add 802.1Qav settings to eth mgmt api
This commit adds a possibility to use Qav (credit-based shaping) in the
ethernet drivers.

There are two parameters exposed through the mgmt api: deltaBandwidth
and idleSlope.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-07-04 16:27:34 -04:00
Tomasz Gorochowik 22ba08faa3 net: gptp: Send Announce messages with correct GM info
There is no point in sending Announces with GM chosen in BMCA if it is
expired and InfoIS is changed to MINE.

Check where does the GM info come from and fill the Announce packet
accordingly.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-07-04 16:26:35 -04:00
Tomasz Gorochowik 1a0968bd74 net: gptp: Normalize seconds and nanoseconds differences
Do not allow seconds and nanoseconds drifts to have the opposite signs.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-07-04 16:26:35 -04:00
Tomasz Gorochowik fd62617ce2 net: gptp: Fix memcpy calls on arrays
Copy array content, not pointers.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-07-04 16:26:35 -04:00
Tomasz Gorochowik 2ca3b1e3c4 net: if: Fix TX timestamp callbacks invocation
The problem is that net_if_call_timestamp_cb only checked if the
callback was registered for the PORT which invoked the whole action.

There is a possibility, that the callback will be registered, and packet
A will be passed to eth driver. Before the driver is finished with
packet A, network layer will start handling another packet (B) - so it
will unregister the callback for packet A and register it for B. After
that the network driver will finish processing packet A and invoke the
timestamp callback. The mechanism would then only check if a callback is
registered for the port of the driver and invoke the callback for the
packet that was registered earlier (so A instead of B).

This commit fixes that by storing info not only about the port but about
the packet too.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-07-04 16:26:35 -04:00
Jukka Rissanen 65e9177a27 net: gptp: Print port state change information
If debugging is enabled, then print port state change information.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-07-04 16:26:35 -04:00
Tomasz Gorochowik fb6223b893 net: gptp: Drop the older pdelay req after receiving a new one
Previously the newer one got dropped.

The older ones will be dropped in a way that the follow up messages for
them will not be sent.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-07-04 16:26:35 -04:00
Tomasz Gorochowik 214aebc6e1 net: gptp: Fix gptp port number validation
The gptp port number starts from 1, so the check was incorrect.
Use the proper define values before printing stats.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-07-04 16:26:35 -04:00
Jukka Rissanen 5356ee5d20 net: gptp: Init only the ports we have configured
The MI state machine was init with too many ports, even if
we only had one of them.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-07-04 11:22:23 -04:00
Jukka Rissanen e9228a3964 net: gptp: Allow gPTP to run over VLAN
Allow this setup as Linux supports this too.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-07-03 20:26:31 +03:00
Jukka Rissanen 65b15c3226 net: eth: Add helper to return VLAN info for an interface
A small helper function will return information whether
a given network interface has VLAN enabled or not.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-07-03 20:26:31 +03:00
Jukka Rissanen 3fd2d53e56 net: mgmt: Add VLAN enabled / disabled event support
Send network management event if VLAN tag is enabled or disabled.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-07-03 20:26:31 +03:00
Jukka Rissanen f3146c09ab net: gptp: Fix buf leak in PDELAY_REQ send
Do not clear pending PDELAY_REQ pointer when sending a new one.
Unref the state->tx_pdelay_req_ptr first and only then set the
new pointer value. This will prevent buffer leak if we miss the
response from the peer.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-07-02 16:52:49 +03:00
Tomasz Gorochowik 5e3ea84e64 net: gptp: Use calculated neighbor ratios only once
Make sure that the calculated ratio values are used just once.
Without this, if the ratio is even insignificantly larger than 1, the
actual clock quickly drifts to really large numbers. This causes the
sync procedure to restart too often.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-07-02 16:52:49 +03:00
Tomasz Gorochowik 93fe54d148 net: gptp: Fix sync timestamp callback registration
The logic was inverted which prevented the callback from ever being
registered.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-07-02 16:52:49 +03:00
Tomasz Gorochowik 7e545c998c net: gptp: Do not handle multiple pdelay requests at once
The problem with the previous approach was that the response timestamp
callback which calls net_pkt_unref could be skipped if the callback was
already registered for another packet. The net_pkt_ref function was
always called which led to memory leaks.

This commit simply disallows handling multiple pdelay requests at once.
If the timestamp callback is already registered, the received request
will not be handled.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-07-02 16:52:49 +03:00
Tomasz Gorochowik b422d38650 net: gptp: Fix sync follow up packets content
The issue was that the length field of the tlv extension in the sync
follow up packets was wrong. It is supposed to skip the length of the
header of that extension. The easiest fix was separating the header and
the actual contents into separate structs and that's what this commit
does.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-07-02 16:52:49 +03:00
Jukka Rissanen cf272e6667 net: gptp: Use the ptp clock instead of zephyr uptime
As the PTP clock should return the correct time, use that
instead of zephyr uptime for time as that has only ms accuracy.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-07-02 16:52:49 +03:00
Jukka Rissanen 70b60cca1d net: gptp: Set priority of the sent gPTP packets
Use priority 3 (critial app) for outgoing event messages (Sync,
Pdelay_Req and Pdelay_Resp). Use priority 6 (Internetwork Control)
for all other outgoing packets.
See IEEE 802.1Q chapter 8.4.4 for more details.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-07-02 16:52:49 +03:00
Dong Xiang 7ba7119f82 net: l2: Fixed wifi can not connect to open AP.
When connect to open AP, the security is always set to
WIFI_SECURITY_TYPE_PSK.

Signed-off-by: Dong Xiang <dong.xiang@unisoc.com>
2018-07-02 15:19:37 +03:00
Tomasz Bursztyka 922d63cee5 net/arp: Normalize all function names
Let's follow the same prefix for all function.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-06-29 12:57:45 +03:00
Tomasz Bursztyka 2df23f567b net/arp: Let's reduce the size of each ARP entry
An ARP entry, if not free, will be either in pending list or in the ARP
table. What differentiate both is the type of data they hold: either a
pending packet or an actual ethernet address.

It is then possible to unite these 2 attributes to save 4 bytes
per-entry.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-06-29 12:57:45 +03:00
Tomasz Bursztyka 35a7804cdf net/arp: Centralize ARP request timeout through one k_delayed_work
Until now, each ARP entry had a k_delayed_work to be used as a timer
when the ARP entry is a pending one, waiting for the ARP request to
succeed in order to get to the ARP table.

But k_delayed_work is not a small object (40 bytes). Thus reworking the
ARP request timer by having one central k_delayed_work and a timestamp
in every ARP entry properly handled at every timeout (1+ entry might
have reached the timeout then).

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-06-29 12:57:45 +03:00
Tomasz Bursztyka 0025a3fce2 net/arp: Optimize ARP table by switching to various single list
Instead of looping over the entries array, which will keep the same
order, let's use slist: one for free entries, one for pending ones and
finally one as the actual ARP table.

This permits some optimizations in how to look up and making small
heuristics by changing entries order when it seems relevant.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-06-29 12:57:45 +03:00
Tomasz Bursztyka 89eeba4250 net/arp: No need to expose publicly arp header
ARP is something internal to ethernet L2, let's just hide its header
file.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-06-29 12:57:45 +03:00
Jukka Rissanen 67b4c5d5d4 samples: net: gptp: Sample application for gPTP support
The application does not do much, it just registers to a callback
in order to get information about gPTP.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-06-28 16:50:50 +03:00
Jukka Rissanen 45b06a252f net: gptp: Initial core IEEE 802.1AS support
Core IEEE 802.1AS-2011 (gPTP) support and application interface.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Signed-off-by: Julien Chevrier <julien.chevrier@intel.com>
2018-06-28 16:50:50 +03:00
Jukka Rissanen 8ae6bad21d net: l2: Move the layer 2 code into subsys/net/
The subsys/net/ directory is more logical place for L2 code instead
of ip/ directory. No functionality changes by this commit.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-06-27 17:02:59 +03:00