Commit graph

463 commits

Author SHA1 Message Date
Ulf Magnusson 48753144bd kconfig: ethernet: Remove duplicated dependencies
Some of these are from 'source'ing a file within a menu that has a
'depends on NET_L2_ETHERNET' (in drivers/ethernet/Kconfig) and then
adding another 'depends on NET_L2_ETHERNET' within it.

Similarly, subsys/net/l2/ethernet/Kconfig sources files within an
'if NET_L2_ETHERNET'.

'if FOO' is just shorthand for adding 'depends on FOO' to each item
within the 'if'. Dependencies on menus work similarly. There are no
"conditional includes" in Kconfig, so 'if FOO' has no special meaning
around a source. Conditional includes wouldn't be possible, because an
if condition could include (directly or indirectly) forward references
to symbols not defined yet.

Tip: When adding a symbol, check its dependencies in the menuconfig
('ninja menuconfig', then / to jump to the symbol). The menuconfig also
shows how the file with the symbol got included, so if you see
duplicated dependencies, it's easy to hunt down where they come from.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-08 07:23:02 -05:00
Johann Fischer 5d14f94c73 drivers: eth_enc28j60: fix calculation of frame length
Fix calculation of frame length in eth_enc28j60_rx().
The calculation was incorrect because the CRC size was
subtracted only from the lower byte.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2019-03-07 20:26:18 -05:00
Tomasz Gorochowik 35b7fde8a6 drivers: eth: gmac: fix screening registers limit check
The j iterator is used for priorities, and the i iterator is used for
choosing the actual screening register. Therefore the screening register
availability needs to be checked with i.

This commit also improves the readability by doing two things:
* by moving the screening register index check to a place where the
  index is going to be actually used
* by using the ARRAY_SIZE macro instead of a hard-coded number as the
  upper limit

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2019-03-06 11:43:17 -06:00
Johann Fischer 45c6ead099 drivers: eth_enc28j60: fix typo and build for half duplex
Fix typo and build for half duplex configuration.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2019-03-05 13:38:43 -05:00
Tomasz Gorochowik 0d1665e93a drivers: eth: gmac: kconfig: remove unused kconfig symbol
The feature that used this symbol was removed in 18b07e09e0.
This is just a cleanup commit that removes the unused symbol.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2019-03-01 19:45:54 +01:00
Paul Sokolovsky fd7c4430e1 drivers: eth: stellaris: Properly ifdef stats handling
Ethernet stats should be added/handles only if
CONFIG_NET_STATISTICS_ETHERNET is defined.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-03-01 09:44:01 -08:00
Daniel Leung 0ccb2af9ba eth: eth_dw: rename CONFIG_ETH_DW_0_IRQ_SHARED_NAME to DT_*
These options were removed from kconfig in previous patch. So rename
the leftovers as shared_irq driver options are defined in DTS now.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2019-03-01 09:42:56 -08:00
Ulf Magnusson 40436f730b kconfig: Use a short consistent prompt style
Same change as in commit 8cf8db3a73 ("Kconfig: Use a short, consistent
style for prompts"), fixing stuff that got introduced since then.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-02-27 09:23:30 +01:00
Tomasz Bursztyka f01f278179 drivers/ethernet: Fix net API usage in smsc911x driver
Fixes #13484

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-21 09:34:30 -05:00
Tomasz Bursztyka 236c5fa48d drivers/ethernet: Removing unused variables in stellaris driver
In was generating these warnings:
eth_stellaris.c:66:8: warning: unused variable ‘eth_hdr’
eth_stellaris.c:65:8: warning: unused variable ‘head_len_left’

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-21 09:34:30 -05:00
Tomasz Bursztyka 12b1381fa1 drivers/ethernet: Switch stellaris driver to new net_pkt API
Allocating all the necessary buffer at once.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-21 09:34:30 -05:00
Tomasz Gorochowik f0db8772f5 eth: eth_mcux: wait in send for the packet to be sent [REVERT ME]
Wait in the send callback for the packet to be actually sent.
After this change, only one TX packet will be handled at once.
This is needed because of the way the TX packets are currently handled
in L2 after this PR: #12563

This is similar to what #13167 did for the SAM GMAC on SAM E-70.

Without this, packet time-stamping does not work with the current stack.

This commit is minimalistic on purpose to make it easily revertible when
the network stack is able to properly handle DMA drivers for TX packets
again.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2019-02-21 09:27:47 -05:00
Aurelien Jarno 413ede4b89 driver: eth: gmac: remove ring_buf usage in the RX path
The ring_buf implementation is basically used as an array of net_buf
pointers in the RX path. The tail and head indexes are taken from the
RX descriptors and not from the ring_buf. That's why for example the
fact that head is never initialized doesn't cause problem. Only len is
used in free_rx_bufs(), but anyway this function is plainly broken as
it always free the first net_buf and doesn't set it back to NULL.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2019-02-14 22:15:29 -05:00
Aurelien Jarno cc1d1478ac driver: eth: gmac: wait until the packet is sent before returning
Scale down the TX path of the GMAC driver by waiting for a packet to be
fully sent before returning from the send function. This has a small
performance impact, but has a few advantages:
- It allows the Ethernet code to modify the packet afterward, fixing PTP
  support on this board (see PR #12563).
- It returns an error to the IP stack in case of a transmit failure.
- It doesn't require net_buf to be thread safe.

This change can be reverted by changing GMAC_MULTIPLE_TX_PACKETS from 0
to 1.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2019-02-14 22:15:29 -05:00
Tomasz Bursztyka ebd2edbaaf drivers/ethernet: Switch SMSC911x to new net_pkt API
It was still using old allocator and net_pkt function to read/write the
data.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-12 20:24:02 -05:00
Aurelien Jarno 9072d34f30 drivers: eth: gmac: drop compile-time check about number of TX packets
The GMAC driver tries to ensure that it can always send a complete
Ethernet frame. However in the TX path this is the problem of the IP
stack: if the buffers can't be allocated, they won't be sent. Therefore
just drop the check.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2019-02-12 15:38:06 -05:00
Aurelien Jarno 9e0748311f drivers: eth: gmac: reduce ETH_SAM_GMAC_BUF_RX_COUNT
Now that the RX packets are limited to the RX workqueue only, we can
reduce ETH_SAM_GMAC_BUF_RX_COUNT to 12 and still be able to receive a
full Ethernet frame. This reduces the minimum NET_BUF_RX_COUNT required
by this driver to 24.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2019-02-12 15:38:06 -05:00
Aurelien Jarno 96a6e40bee Revert "drivers: eth: gmac: conservatively compute the number of descriptors"
This reverts commit afbee4c96a. The IP
stack has been fixed and does not use the RX packets or buffers to
transmit data.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2019-02-12 15:38:06 -05:00
Tomasz Gorochowik 436f1123c8 eth: eth_mcux: Fix the DT_ prefixed defines
Commit 040d6b6e99 (eth: eth_mcux: Convert to use DT_ prefixed defines)
changed all the defines, but to incorrect ones.

This commit changes them to what actually gets generated.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2019-02-11 09:39:28 -06:00
Kumar Gala 040d6b6e99 eth: eth_mcux: Convert to use DT_ prefixed defines
The eth mcux driver has been using non DT_ prefixed defines for DT
generated defines.  Switch to use DT_ prefixed ones as we want to
deprecated the non DT_ prefixed defines.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-02-08 16:03:17 -06:00
Andrei Gansari 1d50a09575 drivers: eth_dw: changed stranded error message
Replaced CONFIG_NET_DEBUG_L2_ETHERNET with
CONFIG_ETHERNET_LOG_LEVEL >= LOG_LEVEL_DBG

Signed-off-by: Andrei Gansari <andrei.gansari@nxp.com>
2019-02-08 13:57:55 +02:00
Aurelien Jarno fa91da4992 drivers: eth: gmac: only keep a reference to the packet when PTP is used
The SAM GMAC Ethernet driver currently keeps a reference to the packet
being sent in addition than keeping of references of the fragments. In
practice this is only needed when PTP is enabled, otherwise the driver
only need to prevent the fragment (or even their content) to be changed.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2019-02-08 12:41:11 +02:00
Aurelien Jarno 757d86b241 drivers: eth: gmac: keep a reference to the packet fragments
The SAM GMAC Ethernet driver uses scatter gather DMA to transmit data.
Each fragment of a network packet is mapped from a set of descriptors
that is used by the controller to do the DMA transfer. This means that
the packet is not necessary sent when the send() function returns. For
that reason the driver calls net_pkt_ref() on the packet to prevent it
from being freed. It is then unreferenced with net_pkt_unref() in the
TX ISR when the packet has effectively been sent.

However this doesn't work if the packet is modified in the meantime,
like it will be done in PR #12563 to remove the Ethernet header
contained in the first fragment. To avoid that, call net_pkt_frag_ref()
on each fragment of the packet, and unreferenced them with
net_pkt_frag_unref() in the TX ISR when the packet has effectively been
sent.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2019-02-08 12:41:11 +02:00
Peter A. Bigot 4d7c06702c drivers: eth_sam_gmac: replace deprecated API
Replace the sole use of i2c_burst_read_addr with a more generic API
function to allow the former to be deprecated along with its unreliable
sibling write and update functions.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-02-07 22:04:28 -05:00
Daniel Leung 7695a72e3c drivers/interrupt_controller: shared_irq: configure by device tree
This allows the shared_irq driver to be configured by device tree.
With previous implementation, only the board configuration can
override the IRQ trigger, as the trigger config is a "choice" rather
than "config". With this patch, the driver can be fully configued at
the SoC level.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2019-02-06 07:18:15 -05:00
Tomasz Bursztyka c14a5c896f drivers/ethernet: Use new net_pkt API for sending and receiving
Use the new API where relevant. Only sam_gmac is left aside for now.

This simplifies a lot the code as the caller should only care about
allocating net_pkt and its buffer once, and thus will not need to mess
with "frags" etc...

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-01 14:34:38 +02:00
Andrei Gansari addafb8222 mimxrt1050_evk: eth_mcux: prevent PHY NANDTree
Force Operation Mode Strap Override register to disable NANDTree. This
is due to some users reporting PHY entering NANDTree.

Signed-off-by: Andrei Gansari <andrei.gansari@nxp.com>
2019-01-31 13:22:58 -06:00
Andrei Gansari 0787936d15 mimxrt1050_evk: eth_mcux: driver fixup
Boot PHY initialization timeout, caching mechanism fixes and networking
buffer descriptors moved to no cache section. Enabled cache management
in networking driver and manual barriers.

Signed-off-by: Andrei Gansari <andrei.gansari@nxp.com>
2019-01-31 13:22:58 -06:00
Andrei Gansari 6d36f2e2f4 mimxrt1050_evk: cache enable
Cacheing mechanisms enabled and non-cache area added.

Signed-off-by: Andrei Gansari <andrei.gansari@nxp.com>
2019-01-31 13:22:58 -06:00
Aurelien Jarno b73c9b32e8 drivers: eth: gmac: fix IRQ names following import of latest HAL
Previous SAM E70 HAL version was patched by commit 4dcfc8706 ("Add
missing interrupt number definitions") to add missing interrupt
definitions for SAM GMAC Priority Queues. This has been fixed in the
latest HAL by using a slightly different name. This patch updates the
driver accordingly.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2019-01-30 10:43:45 -06:00
Aurelien Jarno 4575f44337 drivers: eth: gmac: get rid of descriptors helpers
Now that the descriptor lists are in non-cached memory, the helpers are
just accessing the w0 or w1 members of the structure. Just drop them and
access the members directly.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2019-01-30 08:40:00 -05:00
Aurelien Jarno d144639e47 drivers: eth: gmac: use non-cached memory for descriptor lists
Atmel SAM Ethernet module is using a scatter-gather technique to
exchange data with the Ethernet driver. To communicate the location
of the data buffers the driver sets-up a so called descriptor list. This
is effectively a place in RAM containing a sequence of 32-bit words
representing buffer location and its status.

Currently the cache coherency is handled using cache clean or
invalidate. Unfortunately this strategy only works correctly when the
corresponding data size is a multiple of the cache line. This is not
the case here and might lead to data loss or corruption.

Instead of using cache operations, this patch moves the descriptor
listed to the recently added non-cached memory region, as recommended by
ATMEL. A data synchronisation barrier is still required for writes, as
the non-cached memory is defined with TEX=1, i.e. it is not strongly
ordered. The descriptor lists alignment can be decreased to 4 bytes, as
required by the SAM Ethernet module.

The RX/TX buffer are left unchanged, still managed by cache operations.

Fixes #9812

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2019-01-30 08:40:00 -05:00
Aurelien Jarno 138306598d drivers: eth: gmac: drop wrong cache clean operation
The RX buffer accounting list is not a list shared with Ethernet device,
therefore there is no need to run a cache clean operation on it.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2019-01-30 08:40:00 -05:00
Aurelien Jarno 33dae59a57 drivers: eth: gmac: fix race condition in packet reference counting
The SAM E70 GMAC ethernet driver reference a packet with net_pkt_ref()
when queueing a packet, and unreference it with net_pkt_unref() in the
ISR when it has been fully sent.

The call to net_pkt_ref() is done just after re-enabling the
interruptions, so there is however a small race condition that might
cause the packet to be unreference before being referenced. This is
only theoretical and has not been seen in practice.

Fix that by moving the call to net_pkt_ref() just before re-enabling
the interruptions.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2019-01-29 09:23:52 +02:00
Daniel Glöckner d678f309b8 net: pkt: convert remaining users of ref to atomic_ref
The previous commit replaced the net_pkt element ref with an element
atomic_ref. CI tests turned up more places where ref was used directly.
This commit converts them to use the new element.

Signed-off-by: Daniel Glöckner <dg@emlix.com>
2019-01-29 09:22:14 +02:00
Paul Sokolovsky 364751e029 drivers: eth_mcux: Optimize check if received frame too large
For some reason, there was sequence like:

1. Get size of RX packet.
2. Allocate pkt buffer.
3. Check if the size of RX packet is too large, then deallocate pkt
buffer and error out.

Instead, reorder operations to check size before allocating buf.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-01-29 09:18:43 +02:00
Maureen Helm 605e599b1a ext: mcux: Add HAS_MCUX_ENET config
Adds a new config HAS_MCUX_ENET to constrain which socs can enable the
mcux ethernet driver. This will prevent users from enabling the driver
on socs like kl25z or kw41z which do not have ethernet mac hardware.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2019-01-28 21:21:01 -05:00
Kumar Gala 668443bc74 drivers: eth_enc28j60: Fix CS GPIO support
We now generate CS GPIO defines from the DTS that we can utilize.  We
needed to slightly update the #defines in the driver from:

DT_MICROCHIP_ENC28J60_0_CS_GPIOS_{PIN,CONTROLLER} to
DT_MICROCHIP_ENC28J60_0_CS_GPIO_{PIN,CONTROLLER}

Fixes #12640

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-01-24 08:38:27 -05:00
Aurelien Jarno 87cf468959 drivers: eth: gmac: fix TX descriptor write process
The SAM E70 Ethernet driver uses scatter gather DMA to transmit data.
Each fragment of a network packet is mapped from a set of descriptors
that is used by the controller to do the DMA transfer. Each descriptor
contain an address and a length/status. The important status bits are
GMAC_TXW1_LASTBUFFER to indicate the last fragment of a packet and
GMAC_TXW1_USED to indicate that a descriptor has been processed by the
controller.

When starting a transmission, the controller start at the descriptor
after the last one that has been processed. If the descriptor is NOT
flagged by GMAC_TXW1_USED, it sends a first packet by sending all the
fragments up to a descriptor flagged with GMAC_TXW1_LASTBUFFER. The
first descriptor of a packet *and only the first descriptor of a packet*
is then modified to flag it with GMAC_TXW1_USED and to provide a status
(mostly related to errors and checksum offloading). It then continues
with the next packet and so on and only stops if the next descriptor
after GMAC_TXW1_LASTBUFFER is flagged with GMAC_TXW1_USED.

Therefore in order for the controller to stop processing descriptors,
the strategy is to flag the next descriptor after the last fragment to
be sent with GMAC_TXW1_USED. When the next packet has to be queued, the
flag can be removed before starting a transmission.

This is what is currently done in the current driver. However there is a
small race condition in the implementation: if packets are queued fast
enough, the controller is still sending the fragment of the previous
packet when the descriptor are written. When writing the first
descriptor, the GMAC_TXW1_USED flag is removed. This is done after
writing the address (with a memory barrier) so that looks safe. However
given that the GMAC_TXW1_USED flag is only added by the controller to
the first descriptor of a packet it means the next descriptor might
have it cleared. In that case the descriptor is processed, and a junk
packet is sent. That also desynchronize eth_tx and tx_complete as one
or more packets than expected are transmitted.

In order to fix that the strategy is slightly changed to initially write
the first descriptor with the GMAC_TXW1_USED flag set. Once all the
descriptors from the packet are written the bit is cleared (after a
memory barrier). Then the transmission can be started safely.

The patch also does a small optimization writing the next descriptor
with only the GMAC_TXW1_USED bit set instead of setting this bit. As
this will be a non-cached area, it's better avoiding a read followed
by a write if not necessary.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2019-01-22 15:40:05 +02:00
Aurelien Jarno afbee4c96a drivers: eth: gmac: conservatively compute the number of descriptors
If a pkt has more frags than the number of TX descriptors, we end up in
a deadlock situation, as the whole packet and thus all the frags have to
be mapped in the descriptors at once. That is why the number of
descriptors is defined as CONFIG_NET_BUF_TX_COUNT + 1.

This wrongly assumes that only TX buffers can be used to send data,
however the packets might also come from the RX buffers, like for
example with ICMPv4.

Therefore define the number of descriptors as the maximum of
CONFIG_NET_BUF_RX_COUNT + 1 and CONFIG_NET_BUF_TX_COUNT + 1. This fixes
a deadlock when CONFIG_NET_BUF_TX_COUNT is much smaller than
CONFIG_NET_BUF_RX_COUNT.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2019-01-22 15:40:05 +02:00
Aurelien Jarno 18b07e09e0 drivers: eth: gmac: drop TX timeout handling
The current SAM E70 Ethernet driver sometimes get stuck if the stack
has to send 2 packets in a row, for example an ack for the just received
data + answer data.

The problem is the following one:
1) The first packet goes through eth_tx, one tx_desc_sem semaphore is
   taken, and the tx_timeout_work delayed work is submitted.
2) The second packet also goes through eth_tx, another tx_desc_sem
   semaphore is taken, and the tx_timeout_work delayed work is not
   started because there is already one already submitted.
3) The first packet has been sent, one tx_desc_sem semaphore is given
   and the tx_timeout_work delayed work is cancelled.
4) The second packet has been sent but given the delayed work has
   already been cancelled, tx_completed is not called: the tx_desc_sem
   semaphore is not given back and the network packet is not
   unreferenced.

The whole timeout concept probably has to be reworked. In the meantime
it is probably better to just drop the timeout code instead of keeping
the driver broken. We can only get stuck on the TX path if there is a
bug in the driver or a hardware malfunction. It might happen, but with
the less probability then the current hangs. In addition it just hides
the real issues and prevent them to be fixed.

This commit therefore just remove the timeout code in the TX path.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2019-01-22 15:40:05 +02:00
Paul Sokolovsky 416d397233 drivers: eth_mcux: By default use 1 buffer each for hardware RX/TX
It was reported, and confirmed by multiple parties that default
CONFIG_ETH_MCUX_RX_BUFFERS=2 under some packet load leads to
1s and increasing packet processing delay and eventual deadlock.
No reports were about CONFIG_ETH_MCUX_TX_BUFFERS=2, but be on safe
side and just set that to the minimal value as the current default,
to allow us to have good conservative base to test various networking
stack issues.

Fixes: #3132

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-01-21 12:40:33 +02:00
Paul Sokolovsky 483b9d609c drivers: eth_smsc911x: Add driver for SMSC9118 aka LAN9118 chip
As emulated by QEMU. SMSC9118 is compatible with SMSC9220 as used in
ARM MPS2 board, as well as SMSC9115/6/7/etc. devices.

Portions of the code are based on mbedOS code from its
targets/TARGET_ARM_SSG/TARGET_CM3DS_MPS2/device/drivers/smsc9220_eth.c

eth_smsc9220_priv.h originally comes from Arm mbedOS file:

targets/TARGET_ARM_SSG/TARGET_CM3DS_MPS2/device/drivers/smsc9220_eth.h

augmented with struct & defines from:

targets/TARGET_ARM_SSG/TARGET_CM3DS_MPS2/device/CM3DS.h

and renamed as eth_smsc911x_priv.h to follow Zephyr conventions.

Then, following changes applied:

Changes to build under Zephyr, changes to use symbolic constants
and field access helpers, typo fixes, etc.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-01-19 11:59:29 -05:00
Andrei Gansari 4118b8843f drivers: eth_enc28j60: moved to dts
Driver for networking device Microchip ENC28J60 is used as SPI slave,
moved to DTS type definition. Samples echo_client and echo_server use
this device on Arduino 101 board.

Signed-off-by: Andrei Gansari <andrei.gansari@nxp.com>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-01-16 21:28:23 -05:00
Paul Sokolovsky f3dce8a6e4 drivers: eth: stellaris: Enable automatic Ethernet support in QEMU
When used suitable config overlay, qemu_cortex_m3 with Ethernet
support can be started with just usual "make run".

An example of such overlay is included with samples/net/echo_server,
can be built and run with:

make BOARD=qemu_cortex_m3 \
    CONF_FILE="prj.conf overlay-qemu_cortex_m3_eth.conf" run

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-01-11 09:48:27 +02:00
Sebastian Bøe 92ccd2ccd8 kconfig: Refactor the dependency on 'NET_L2_ETHERNET'
Refactor the dependency on 'NET_L2_ETHERNET'.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-12-30 16:24:50 -05:00
Sebastian Bøe 2b89316a52 kconfig: Fixed missing dependency for ETH_SAM_GMAC
The Kconfig option ETH_SAM_GMAC was missing it's dependency on
NET_L2_ETHERNET. Before this patch Kconfig was allowing users to
enable the driver, but the driver was not added because the CMake code
only adds the driver when NET_L2_ETHERNET.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-12-30 16:24:50 -05:00
Sebastian Bøe 204f05b23a kconfig: Minor comments and 'help' text fixes
Minor comments and 'help' text fixes.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-12-30 16:24:50 -05:00
Jukka Rissanen 9019207964 drivers: eth: gmac: Remove extra variable
The msg_start variable was declared twice.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-12-14 18:34:16 +02:00
Tomasz Bursztyka 7f8d92827f net/ethernet: Remove usage of net_pkt_ll() function
This function is planned to be removed, thus avoiding its usage.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-12-14 14:16:37 +01:00
Tomasz Bursztyka e97a543e9b net/pkt: Remove parameters to "reserve" some headroom
Such parameter is not used anymore, it was defaulted to 0 previously.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-12-14 14:16:37 +01:00
Tomasz Bursztyka bff65b6330 net/ethernet: Let's remove the use for ll reserve
There is no need to reserve any space for each frag, as the l2 will
allocate a frag for the ethernet header, arp will do the same.

This is one step further to removing the concept of ll reserve.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-12-14 14:16:37 +01:00
Jukka Rissanen 3e8b2a0a37 drivers: eth: native_posix: Fix gPTP header parsing
We were reading gPTP header from wrong position when parsing
it in RX and TX.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-12-11 13:50:54 +02:00
Jukka Rissanen 32f02138dc drivers: eth: sam-e70: Fix gPTP header parsing
We were reading gPTP header from wrong position when parsing
it in RX and TX.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-12-11 13:50:54 +02:00
Jukka Rissanen 7503228ad0 drivers: eth: mcux: Fix gPTP header parsing
We were reading gPTP header from wrong position when parsing
it in RX and TX.

Fixes #11827

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-12-11 13:50:54 +02:00
Erwan Gouriou 9062e97a45 drivers: stm32: check clock_control_on return value
Check clock_control_on return value now that it is checking appropriate
bus is used in the request.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2018-12-07 11:31:48 -05:00
Jukka Rissanen ff0483c5af net: gptp: Get the gPTP header properly
If the link layer header is in the separate net_buf,
then skip that one.

Fixes #11827

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-12-07 16:43:59 +02:00
Tomasz Bursztyka 8a8d4d3070 drivers/ethernet: Update RX error statistics relevantly
Update such statistic on all drivers.
Also, remove TX stats in native and stellaris drivers: such update is
done in L2 now.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-12-07 14:30:06 +02:00
Tomasz Bursztyka 538961d109 drivers/ethernet: Remove double unref from stellaris driver
It's now either L2 which unref the pkt on successful tx, or net_if on
error.

Also removing pkt->frags check, net_core.c:net_send_data() does it
already.

And using data_len in logging instead of net_pkt_get_len(), which one is
currently greedy (it goes over all net_bufs).

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-12-07 14:30:06 +02:00
Tomasz Bursztyka 1a59e0abf1 drivers/ethernet: Adapt stellaris driver to new L2 behaviour
L2 is the one who requests the packet to be sent, and not via net_if API
anymore. Stellaris driver was merged right after this behaviour change
and was thus lacking the proper modification.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-12-05 15:04:56 +02:00
Patrik Flykt 8ff96b5a57 drivers: Add 'U' to unsigned variable assignments
Add 'U' to a value when assigning it to an unsigned variable.
MISRA-C rule 7.2

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2018-12-04 22:51:56 -05:00
Vijay Kumar B cffb2d8051 drivers: ethernet: Add TI Stellaris ethernet controller driver.
The driver can be tested using different networking emulation
approaches.

This approach will work across multiple Qemu instances. There can be
more than one Qemu instance, run using the following command. They
would appear to be on the same Ethernet network.

  $ qemu-system-arm -M lm3s6965evb                      \
                    -serial stdio                       \
                    -net nic                            \
                    -net socket,mcast=230.0.0.1:1234    \
                    -kernel zephyr.elf

This approach will work with other virtualization technologies that
support connecting to a VDE switch, like VirtualBox and User Mode
Linux. The switch can be started using the following command.

  $ vde_switch --sock /tmp/switch

Qemu can be connected to the switch using the following command.

  $ qemu-system-arm -M lm3s6965evb                      \
                    -serial stdio                       \
                    -net nic                            \
                    -net vde,sock=/tmp/switch   	\
                    -kernel zephyr.elf

Signed-off-by: Fadhel Habeeb <fadhel@zilogic.com>
Signed-off-by: Nirav Parmar <niravparmar@zilogic.com>
Signed-off-by: Vijay Kumar B <vijaykumar@zilogic.com>
2018-12-04 09:36:51 -06:00
Jukka Rissanen 3ac7c12b4f drivers: eth: native_posix: Enable PTP clock support for gPTP
If gPTP is enabled, then enable also PTP clock driver so that
gPTP sync starts to work properly for native_posix board.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-12-04 01:15:38 -05:00
Jukka Rissanen e694b1a5f9 drivers: eth: native_posix: Fix PTP driver init priority
The PTP driver was init too late which prevented gPTP from
working in native_posix board.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-12-04 01:15:38 -05:00
Jukka Rissanen d641ac6eee drivers: eth: native_posix: Fix gPTP compile error
If compiling with gPTP support for native_posix board, then avoid
compile error that is seen with gptp sample application.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-12-03 14:24:36 +02:00
Tomasz Bursztyka 9464ec3343 net/iface: Switch fully to a one-pass sending logic in net_if
Now instead of such path:

net_if_send_data -> L2's send -> net_if tx_queue -> net_if_tx -> driver
net_if's send

It will be:

net_if_send_data -> net_if tx_queue -> net_if_tx -> L2's send -> driver
net_if's send

Only Ethernet is adapted, but 15.4 and bt will follow up.
All Ethernet drivers are made compatible with that new scheme also.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-11-30 11:12:13 -08:00
Alexander Polleti daf1ba6e52 ethernet: stm32: add MII mode
Add MII mode for STM32 Ethernet in Kconfig. Default is still RMII.

Signed-off-by: Alexander Polleti <metapsycholo@gmail.com>
2018-11-30 10:59:49 -08:00
Andrei Gansari 35ba3aadc4 drivers: eth_mcux: adding i.mx-rt support
Enables Networking hardware on i.MX-RT type drivers.
Reuses the same eth_mcux driver used by Kinetis family; initialization
sequence refactored to work with this board as well. Unlike Kinetis
family, i.MX has a single ENET interrupt and we need to discriminate
between interrupts using a status register.

Signed-off-by: Andrei Gansari <andrei.gansari@nxp.com>
2018-11-20 09:54:25 -06:00
Andrzej Głąbek 20202902f2 dts_fixups: Use DT_ prefix in all defined labels not related to Kconfig
These changes were obtained by running a script  created by
Ulf Magnusson <Ulf.Magnusson@nordicsemi.no> for the following
specification:

1. Read the contents of all dts_fixup.h files in Zephyr
2. Check the left-hand side of the #define macros (i.e. the X in
   #define X Y)
3. Check if that name is also the name of a Kconfig option
   3.a If it is, then do nothing
   3.b If it is not, then replace CONFIG_ with DT_ or add DT_ if it
       has neither of these two prefixes
4. Replace the use of the changed #define in the code itself
   (.c, .h, .ld)

Additionally, some tweaks had to be added to this script to catch some
of the macros used in the code in a parameterized form, e.g.:
- CONFIG_GPIO_STM32_GPIO##__SUFFIX##_BASE_ADDRESS
- CONFIG_UART_##idx##_TX_PIN
- I2C_SBCON_##_num##_BASE_ADDR
and to prevent adding DT_ prefix to the following symbols:
- FLASH_START
- FLASH_SIZE
- SRAM_START
- SRAM_SIZE
- _ROM_ADDR
- _ROM_SIZE
- _RAM_ADDR
- _RAM_SIZE
which are surprisingly also defined in some dts_fixup.h files.

Finally, some manual corrections had to be done as well:
- name##_IRQ -> DT_##name##_IRQ in uart_stm32.c

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2018-11-13 10:44:42 -06:00
Jukka Rissanen 55f009d8e5 drivers: eth: e1000: Free packet after sending it
The error check was wrong, if we could send the packet then
we free it. If sending fails, then let the caller to decide
what to do with the packet.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-11-13 10:35:39 +02:00
Oleg Zhurakivskyy 064074e62b drivers: eth: e1000: Use system log macros
System log macros now include function names, use them.

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2018-11-12 10:03:51 -05:00
Oleg Zhurakivskyy 3645a7a40d drivers: eth: e1000: Enable multicast
Add "Multicast Promiscuous Enabled" (RCTL_MPE) bit definition and
use it for the receive control register (RCTL) initialization.

Multicast needs to be enabled in order for IPv6 auto-configuration
to succeed.

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2018-11-12 10:03:51 -05:00
Oleg Zhurakivskyy 3c52b11951 drivers: eth: e1000: Enable interrupt in a safe way
The initial sequence was wrong and led to the missing interrupt
problem with netdev backends where the incoming traffic
appears immediately (tap).

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2018-11-12 10:03:51 -05:00
Oleg Zhurakivskyy 69be780db4 drivers: eth: e1000: Call ethernet_init() on init
The driver should call ethernet_init() in order to initialize
Ethernet L2 stack.

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2018-11-12 10:03:51 -05:00
Jukka Rissanen 421505c7e3 net: qemu: Allow SLIP or normal ethernet connectivity
Introduce new Kconfig option for selecting either slip or ethernet
connectivity to host.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-11-10 09:13:45 -05:00
Kumar Gala aa2bdbe322 drivers: Remove board.h include
We either don't need board.h in the driver or we should be include soc.h
instead.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-11-01 13:21:11 -04:00
Jukka Rissanen 82fa5bcf59 drivers: eth: native_posix: Allow non-root access
Change the default behaviour of the host network interface
setup. Now user needs to execute net-setup.sh script from
net-tools project to setup host ethernet interface. The script
needs to be run as a root user. Then zephyr.exe can be started
as a normal user.

Example:
    cd net-tools
    sudo ./net-setup.sh

This will create zeth network interface and set IP address and
routes properly. See other command line options by typing
    ./net-setup.sh --help

Old behaviour is still there if one enables
    CONFIG_ETH_NATIVE_POSIX_STARTUP_AUTOMATIC=y

in which case one needs to use the command
    sudo --preserve-env zephyr.exe

to start the Zephyr process.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-10-23 11:08:39 +03:00
Andrei Gansari 02e217df50 drivers: eth_mcux: kinetis networking device Tree
Partially replaces Kinetis MCUX driver configuration from Kconfig to
Device Tree. Interrputs moved from defines configuration to DT.

Signed-off-by: Andrei Gansari <andrei.gansari@nxp.com>
2018-10-19 07:57:20 -05:00
Christian Taedcke 8d1143c838 drivers: ethernet: stm32: Fix typo in comment
Fix minor typo in code comment.

Signed-off-by: Christian Taedcke <hacking@taedcke.com>
2018-10-15 12:01:22 -05:00
Jukka Rissanen ce8035e280 drivers: eth: e1000: Remove unused variable
The probe function had unused variable which caused compile warning.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-10-15 10:53:53 -04:00
Paul Sokolovsky 87e4dc33b6 driver: ethernet: e1000: Use correct return for device init()
In case of successful detection, return 0. Otherwise, return -ENODEV
error.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-10-12 10:26:42 -04:00
Oleg Zhurakivskyy 65ea181c92 drivers: eth: e1000: Add driver for Intel PRO/1000 Ethernet controller
This patch adds a driver for Intel PRO/1000 Gigabit Ethernet controller.

The driver currently supports only a single instance of the NIC.

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2018-10-10 04:17:15 -04:00
Jukka Rissanen 009e4dafa7 net: Make Kconfig template variables prettier
Adding spaces around "=" when definining Kconfig template so
that is more consistent with overall style of these template
variables.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-10-05 09:01:37 -04:00
Jukka Rissanen 20295c821b drivers: eth: Convert to use new logging
Convert the ethernet drivers to use the new logging system.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-10-04 14:13:57 +03:00
Daniel Leung e2c590a0c4 drivers: ethernet: native: fix compile error when glibc >= 2.20
Starting with glibc 2.20, there is warning when _BSD_SOURCE is defined
but not _DEFAULT_SOURCE (in /usr/include/features.h around line 184).
Sanitycheck turns this warning into error. So define _DEFAULT_SOURCE
at build time for native.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2018-09-28 11:32:09 +03:00
qianfan Zhao 15959c8b85 drivers: eth_sam: Add generate random mac address feature
Using a random mac address with Atmel's OUI if enabled this feature

Signed-off-by: qianfan Zhao <qianfanguijin@163.com>
2018-09-27 21:52:14 +03:00
Alberto Escolar Piedras c065ebdfc2 drivers: ethernet: native: Fix compile issue in RedHat 7
Fix 2 compile issues in RedHat/CentOS 7 for the native
ethernet driver due to a oldish glibc, which does not include
by default the needed structures.
+
Separate the native ethernet driver into its own library,
and set NO_POSIX_CHEATS for it, in case the Zephyr POSIX
library would eventually add support for any of the host functions
used in this driver.

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2018-09-26 13:06:08 +03:00
Tomasz Gorochowik 233020650f drivers: eth: gmac: Proper ptp clock setup
Calculate proper initial PTP clock divisors based on the MCK value.

Additionally do not allow adjusting the rate of the clock. This does not
seem to work properly with current gPTP rate adjustment algorithm.

Having proper PTP clock divisors and callbacks that allow getting,
setting and adjusting current time is sufficient for proper gPTP
support.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-09-19 09:54:29 +03:00
Flavio Ceolin 67ca176754 headers: Fix headers across the project
Any word started with underscore followed by and uppercase letter or a
second underscore is a reserved word according with C99.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2018-09-17 15:49:26 -04: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
Frank Li 4934323931 drivers: eth: enc28j60: Fix read error when ERDPT < ERXRDPT
After read first packet and if ERDPT < ERXRDPT,cause read Rx FIFO error.
The fix is to set ERDPT properly before reading next packet.

Fixed #9537

Signed-off-by: Frank Li <lgl88911@163.com>
2018-08-31 15:46:42 -04:00
Daniel Egger eaca7d78ce drivers: ethernet: Kconfig: Document availability of eth_stm32_hal
The eth_stm32_hal has been tested to work correctly on Nucleo-F207ZG,
Nucleo-F429ZI, Nucleo-F746ZG and Nucleo-F767ZI.

Signed-off-by: Daniel Egger <daniel@eggers-club.de>
2018-08-15 08:17:48 -05:00
Ulf Magnusson 8cf8db3a73 Kconfig: Use a short, consistent style for prompts
Consistently use

    config FOO
            bool/int/hex/string "Prompt text"

instead of

    config FOO
            bool/int/hex/string
            prompt "Prompt text"

(...and a bunch of other variations that e.g. swapped the order of the
type and the 'prompt', or put other properties between them).

The shorthand is fully equivalent to using 'prompt'. It saves lines and
avoids tricking people into thinking there is some semantic difference.

Most of the grunt work was done by a modified version of
https://unix.stackexchange.com/questions/26284/
how-can-i-use-sed-to-replace-a-multi-line-string/26290#26290, but some
of the rarer variations had to be converted manually.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-15 04:10:10 -07: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 f9aa9783d0 drivers: eth: native_posix: Allow user to manipulate zeth status
User can take the zeth interface down by issuing "net iface down <idx>"
shell command. It is possible to take the interface up by typing
"net iface up <idx>" in shell. These commands are important for
native_posix as there is no physical cable that can be connected
or disconnected.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-08-10 12:36:19 +03:00
Tomasz Gorochowik 0ffdd7fbad drivers: eth: gmac: Don't use Qav code without priority queues
Most of this code is unreachable with priority queues disabled because
of queue id validation.

Fixes #9295.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-08-08 14:32:16 +03:00
Jukka Rissanen 3913f1ae2f drivers: eth: Enable LLDP support for native_posix board
Needed for testing LLDP.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-08-08 09:53:24 +03:00
Jukka Rissanen b4e36133c2 drivers: eth: native_posix: Exec program after creating zeth
Allow user to configure a program that is executed after the
network interface is created and IP address is setup.
This can be used e.g., to start wireshark to capture
the network traffic of the interface.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-08-06 14:20:51 +03:00
Tomasz Gorochowik ef96384d25 drivers: eth: gmac: Finish 802.1Qav support
This is a finishing commit in 802.1Qav support for SAM GMAC. It adds a
possibility to get and set all parameters required by the standard.

Note that to be fully compliant it requires a proper system
configuration, but the prioritizing mechanisms will work just fine
without it so it is not enforced in any way.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-08-06 10:37:09 +03:00
Tomasz Gorochowik b15c3cb5b6 drivers: eth: gmac: Prefer routing packets based on TC
If the application is using TC configuration compatible with HW
configuration (equal number of traffic classes and hardware queues)
setup the screening registers and chose queues based on the chosen TC
mapping.

Use the VLAN priority and hard-coded mappings only as a fallback.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-08-06 10:37:09 +03:00
Tomasz Gorochowik 78b6dc6dea drivers: eth: gmac: Do not implicitly enable Qav
Updating Qav params made it implicitly enable the Qav support itself.
Since we can now control the on/off status with a management request,
this is not a desired behavior.

Make it read the original register value before updating params and then
writing back what it was before.

Additionally we now have to explicitly enable Qav support in init.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-08-06 10:37:09 +03:00
Tomasz Gorochowik bdd2e5911f drivers: eth: gmac: Fix idle slope setting
The standard (and therefore the upper layer) is using bits per second,
the registers in SAM GMAC uses bytes per second - do the conversion
before writing the reg.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-08-06 10:37:09 +03:00
Alberto Escolar Piedras 7c776c8c81 net: eth: native_posix: Add missing headers
unistd.h was missing (used by read, close..)

printk header was also missing, but replace it's use
with posix_print_trace: It is faster and does not require
any Zephyr functionality to work.
fflush is not needed in this case.

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2018-08-02 19:14:19 +02:00
Alberto Escolar Piedras 4388cde90f arch posix: Allow including XOPEN extensions
The native_posix random driver uses random() and srandom()
whicha are old XOPEN POSIX extension (part of POSIX 2001).

To avoid compiler warnings due to the host libC headers
not including this prototypes otherwise, let's define
this 2 macros.

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2018-08-02 19:14:19 +02:00
Tomasz Gorochowik 0272a537f9 drivers: eth: gmac: Don't verify RX buffers count for unit tests
There is no need to do that and this makes the compilation of unit tests
fail (See #9224).

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-08-02 10:49:45 +03:00
Ulf Magnusson d1684a83a4 Kconfig: Clean up some symbol definitions
- Remove redundant 'n' defaults. 'n' is the default value for bool
  symbols.

  This makes the auto-generated documentation clearer as well: You get
  "implicitly defaults to n" instead of
  "- n if <propagated dependencies>".

- Shorten

      <type>
      prompt "foo"

  to

      <type> "foo"

  This works for all types, not just bool.

- Various formatting nits.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-01 12:47:17 -04: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 55767ade42 drivers: eth: gmac: Implement Qav status callbacks
Add a possibility to dynamically enable and disable Qav for individual
queues.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-07-31 17:54:24 +03:00
Tomasz Gorochowik 1b6e5f6143 drivers: eth: gmac: Enable 802.1Qav support
This commit makes the driver enable HW Qav support for all available
priority queues.

Note that the hardware doesn't support setting the deltaBandwidth
parameter directly, but it is possible to do this by calculating it
from the negotiated link speed.

The default settings are set according to 802.1Qav 34.3.1, that says:

  The recommended default value of deltaBandwidth(N) for the highest
  numbered traffic class supported is 75%, and for any lower
  numbered traffic classes, the recommended default value is 0%.

The default/recommended values can be changed using the ethernet
management API (set_config) - which this commit also adds.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-07-31 10:25:19 +03:00
Tomasz Gorochowik abd417c078 drivers: eth: gmac: Implement the get_config callback
Handle getting the number of priority queues. The total number of queues
for this driver is configured in kconfig so it is as simple as returning
a defined value in this case.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-07-31 10:25:19 +03:00
Jukka Rissanen 39ec52d2f1 drivers: eth: native_posix: Make sure sent pkt is freed properly
Follow the packet sending error code in the driver. If packet
cannot be sent, then return <0 to the caller and do not free
the packet. In practice this is not happening here but follow
this general rule anyway.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-07-31 10:03:46 +03:00
Tomasz Gorochowik a43ed0f431 drivers: eth: gmac: rework timestamping
Use both PTP Peer Event and PTP Event timestamping registers when
necessary.

Also for non-PTP frames just use current time.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-07-27 20:29:15 +03:00
Tomasz Gorochowik 3dd1101cb3 drivers: eth: gmac: Minor reformatting
This change is needed to make checkpatch happy.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-07-27 20:29:15 +03:00
Tomasz Gorochowik 75d23d5916 drivers: eth: gmac: Add support for multiple hardware queues
This commit adds support for multiple hardware TX and RX queues.
The number of the queues to use can be configured through defconfig.

Packets are sent and received through different hardware queues
depending on their priority.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-07-27 20:29:15 +03:00
Tomasz Gorochowik 4e642f629a drivers: eth: gmac: Fix ptp clock rate re-calculation
This commit fixes how the registers values are calculated and makes sure
there is no overflow effect when converting back to int.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-07-27 20:29:15 +03:00
Tomasz Gorochowik 7dc9831d82 drivers: eth: gmac: Disallow drastic rate changes
This commit makes the driver disallow drastic clock rate changes.
These changes happen mostly in the very beginning, when the timestamp in
hardware is zeroed.
In such cases the set callback is called soon after and fixes the large
offset. Without this limit the clock offset oscillates for a longer
period before it properly syncs as the requested ratio jumps between
very large and very small values.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-07-27 20:29:15 +03:00
Tomasz Gorochowik 9099b24821 drivers: eth: gmac: Use correct iface for gPTP over VLAN
This commit fixes a memory leak happening when both gPTP and VLAN are
enabled.

It also moves the get_iface function up in the file so it is accessible
earlier without a redundant function declaration.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-07-27 20:29:15 +03:00
Tomasz Gorochowik aabaf98c65 drivers: eth: gmac: Enable gPTP support
This adds packet timestamping support to the GMAC driver.
It is based on the eth_native_posix and eth_mcux drivers.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-07-27 20:29:15 +03:00
Tomasz Gorochowik 525b0ce81b drivers: eth: gmac: Restore original frags data after transmitting
The pointers to pkt->frags->data are changed after transmitting.
Other layers (e.g. the gPTP drivers) assume that these will remain
unchanged. This patch adds a workaround for that issue and restores the
original pointers.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-07-27 20:29:15 +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 af44d7c2e8 net: eth: native_posix: Add promiscuous mode support
Allow the zeth network interface to be placed into promiscuous mode.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-07-24 15:12:37 +03:00
Jukka Rissanen 9135b17535 net: eth: native_posix: Return proper error code from linux
Make sure that the system() call will return proper error code
to the ethernet driver.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-07-24 15:12:37 +03: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
Jukka Rissanen 77e03fc8be drivers: eth: mcux: Prioritize received PTP packets to high
Set the received PTP packet priority high so that those packets
will be handled first.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-07-18 07:37:41 -04:00
Jukka Rissanen 18d327c432 drivers: eth: mcux: Allow gPTP over VLAN
If VLAN is enabled for specific PTP interface, then manipulate
the ethernet header properly in this case.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-07-18 07:37:41 -04:00
Jukka Rissanen d45f90e548 drivers: eth: mcux: Enable gPTP support
This adds packet timestammping support to the driver and configures
various PTP options in ENET.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Signed-off-by: Julien Chevrier <julien.chevrier@intel.com>
2018-07-18 07:37:41 -04:00
Jukka Rissanen 16f31f1d3c drivers: eth: native_posix: Enable gPTP support
Allow gPTP code to be run as a linux process and communicate
with gPTP daemon running in linux host.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-07-05 12:53:37 +03:00
Ulf Magnusson 86c46864ee drivers: ethernet: Kconfig: Remove redundant 'default n' properties
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, and is
inconsistent.

This will make the auto-generated Kconfig documentation have "No
defaults. Implicitly defaults to n." as well, which is clearer than
'default n if ...'

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-07-03 17:11:31 -04:00
Paul Sokolovsky ec6b6c9f0c eth: mcux: Add an option for randomized, but stable MAC address
The previous default, CONFIG_ETH_MCUX_0_RANDOM_MAC, result in a random
MAC address changed each reboot. As reboots happen quite often during
development, while Ethernet peers usually cache existing MAC addresses
in ARP cache, this led to situation when a board after reboot didn't
respond to pings or any other connection attempts for random amount of
time (upo to 10-20s). This was quite confusing and looked like some
problem in driver/hardware/connection/whatever.

Instead, introduce new option, CONFIG_ETH_MCUX_0_UNIQUE_MAC, to make
MAC address from MCU unique identification register. This results in
randomized/unique MAC address which is also stable over reboots and
avoids the situation described above.

Fixes: #3187

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-07-03 17:07:33 -04:00
Daniel Egger 536d77ab51 drivers: eth: stm32: Added missing ethernet_init() call
Fixes #8668

Signed-off-by: Daniel Egger <daniel@eggers-club.de>
2018-07-03 15:43:06 +03:00
Tomasz Gorochowik ff41ef477e drivers: eth: gmac: Cast to type expected by HAL
This is needed to avoid compilation warnings when using both the
built-in libc and newlib.
The warnings were caused by typedefs incompatibilities.

This was agreed to be the temporary solution at the TSC.

See #8469 for more details.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-06-27 11:35:57 -05: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
Tomasz Gorochowik 0a6046cf31 drivers: eth: gmac: Ensure caches are enabled before using them
Attempts to clear/invalidate caches which are disabled lead to BUS
FAULTS.

Ensure they are enabled before using them.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-06-19 15:04:16 +03:00
Tomasz Gorochowik a313e5c74f drivers: eth: gmac: Fix cache support for SAM GMAC
What needs to be done for the cache to work properly:
* Make sure cache operations are aligned to 32B
* Make sure to clean and invalidate the operations on gmac descriptors
  (thus all the helper functions)

This commit is needed for SAM GMAC to work when caches are enabled and
MPU mapping is changed to cacheable (See #8185)

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-06-19 10:48:24 +03:00
Ulf Magnusson 8df42eb4dc drivers: Replace ff hex constants with 0xff
This makes it easier to distinguish them from "true" undefined symbols.

Internally, all int/hex literals are treated as undefined symbols, which
always get their name as their value. The C tools work the same way.

The plan is to turn references to undefined Kconfig symbols into an
error later.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-06-13 13:35:56 -04:00
Jukka Rissanen e7206318fa drivers: eth: mcux: Inform IP stack when carrier is lost
If carrier is ON or OFF, then tell this information to upper IP stack
so that it can act accordingly.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-06-11 17:27:29 -04:00
Michael Scott 30dbf3c0e5 drivers: eth: mcux: use CONFIG_SYS_LOG_ETHERNET_LEVEL for syslog level
Don't hard code the syslog level to DEBUG, instead use the
CONFIG_SYS_LOG_ETHERNET_LEVEL setting like other ethernet drivers.

Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
2018-05-31 09:15:52 -05:00
Ruslan Mstoi 29b7cdc8de drivers: eth: native_posix: Fix malformed echo response
Native POSIX echo server sends malformed response to echo request of
size larger than 128 bytes (default size of each network data
fragment). Wireshark notices that by tagging echo request with "No
response seen". This commit fixes that issue.

Signed-off-by: Ruslan Mstoi <ruslan.mstoi@intel.com>
2018-05-30 20:30:19 -04:00
Jukka Rissanen 8f5929ddf0 net: Too long timeout for k_sleep
Convert couple of MSEC() calls to K_MSEC() as the timeouts
when using MSEC() are just too long.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-05-28 17:20:11 -04:00
qianfan Zhao a8d934069e eth_stm32_hal: fix dev_data->mac_addr typo
fix typo: contdev_dataext -> dev_data

Signed-off-by: qianfan Zhao <qianfanguijin@163.com>
2018-05-28 09:31:49 -05:00
Erwan Gouriou d8fd97abe0 drivers/ethernet: stm32: Don't exit driver init on HAL timeout
In case ethernet cable is unplugged, stm32 ethernet driver triggers
an error, driver initialization fails and fw crashes.
This could be enhanced as in case not cable is connected, HAL
returns a Time out, and will resume its initialization when
cable is plugged.
Treat HAL timeout in ethernet driver initialization as a
recoverable error and continues driver init when it happens.

Tested with sample/net/dhcpv4_client. Start board with cable
unplugged. Wait some time before plugging the cable. DHCP request
is correctly performed when cable is plugged.

Fixes: #7127

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2018-05-25 13:07:05 -05:00
Alberto Escolar Piedras a21a075c1d native: ethernet: fix k_sleep() wait time
The input of k_sleep was wrongly converted from ms to ticks.
Fixed.

Fixes: #7656

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2018-05-21 22:34:17 -04:00
David B. Kinder 5e9f7cb27a doc: fix misspellings in Kconfig files
occasional spelling-check scan found some misspellings

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-04-13 08:28:57 -04:00
Jukka Rissanen 3e048f6d3e drivers: eth: native_posix: Add ethernet statistics support
Collect ethernet statistics for this driver.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-04-11 16:49:48 +03:00
Tomasz Bursztyka e8bc063215 drivers/ethernet: Reduce runtime context size in ENC28J60 driver
- tx_tsv is never used anywhere
- and rx_rsv can be allocated on stack

Optimizing a bit the stack usage in eth_enc28j60_rx() function as well.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-04-11 16:28:16 +03:00
Tomasz Bursztyka 669d4a8ccb drivers/ethernet: Optimize memory read/write operations in ENC28J60
SPI API helps to directly transfer bytes from/to relevant buffers, so
let's take advantage of it.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-04-11 16:28:16 +03:00
Tomasz Bursztyka 42902e580b drivers/ethernet: Fix and clean a bit ENC28J60 driver
Driver is still a bit messy, not using for instance the 0-copy
capabilities of SPI API, but this will be fix later.

Constify most of the spi buf structures, removing useless variables,
renaming function with common prefix eth_enc28j60_ etc...

It seems to fix an issue on verifying if tx was successful as well.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-04-11 16:28:16 +03:00
Tomasz Bursztyka 4bf1a9bd60 net/ethernet: All types are prefixed with ethernet_
Aligning eth_hw_caps to the right prefix, so ethernet_hw_caps.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-04-10 14:45:37 +03:00
Tomasz Bursztyka e996b37c0a net/ethernet: Add capabilities exposed by device drivers
Curently only link speed is exposed.
Opportunity taken to remove any post-fix enumerating the iface init
and/or the api: these must be generic and used by all the instances.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-04-10 14:45:37 +03:00
Jukka Rissanen ed923da435 drivers: net: mcux: Use VLAN priority to set RX packet priority
Set the received network packet priority according to VLAN priority.
Currently this mapping is 1:1 but can be changed if needed.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-04-05 08:54:19 -04:00
Jukka Rissanen 73b43e0024 drivers: eth: native_posix: Add VLAN support
Support also virtual LAN (VLAN) with native_posix ethernet driver.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-04-05 08:54:19 -04:00
Jukka Rissanen 02ee3651ed drivers: eth: gmac: Adding VLAN support to Atmel E70 board
This enables VLAN support in gmac ethernet driver.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-04-05 08:54:19 -04:00
Jukka Rissanen 7385e38802 drivers: eth: mcux: Enabling VLAN
This enables / fixes VLAN support in mcux ethernet driver.

The commit contains these changes for enabling VLAN:
* Increase the size of the ethernet frame if VLAN is enabled.
* Enable VLAN in chip if VLAN is enabled
* If VLAN is enabled, then the iface in context struct should
  not be used directly as there can be multiple VLAN iface
  related to this physical device.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-04-05 08:54:19 -04:00
Tomasz Bursztyka b702236d1a drivers/ethernet: No need of semaphore for spi in enc28j60
SPI API is reentrant.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-04-04 19:02:35 +02:00
Matthias Boesl 2a14d289e5 drivers/ethernet: Switch enc28j60 to new SPI API
Let's use the new SPI API and ditch the old one.

Signed-off-by: Matthias Boesl <matthias.boesl@gmail.com>
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-04-04 19:02:35 +02:00
Tomasz Bursztyka 324265420b api/spi: Disable legacy API by default
Let's start deprecation work of the SPI legacy API.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-04-04 19:02:35 +02:00
Jukka Rissanen 22399c327e drivers: eth: native_posix: Enable ethernet by default if needed
As the native_posix board has ethernet driver, then enable it by
default if networking is enabled in prj.conf file. This way we can
use generic networking config file when running the application
for native_posix board.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-04-03 17:47:53 -04:00
Jukka Rissanen 47dafffb67 net: if: Separate IP address configuration from net_if
Move IP address settings from net_if to separate structs.
This is needed for VLAN support.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-03-27 10:06:54 -04:00
Jukka Rissanen 5afa30ccef drivers: eth: native_posix: No need to sleep in select
We can just use polling mode with 0 timeout when waiting data
to arrive from host OS. The 50ms timeout is not needed.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-03-26 15:47:48 +03:00
Jukka Rissanen 85a2459edb net: Support network packet checksum calc offloading
Create infrastructure that allows ethernet device driver to tell
if it supports network packet checksum offloading. This applies only
to IPv4, UDP or TCP checksums. The driver can enable/disable checksum
offloading separately for Tx and Rx network packets.

If the device (ethernet in this case) can calculate the network
packet checksum for IPv4, UDP or TCP, then do not calculate the
corresponding checksum by the stack itself.

Fixes #2987

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-03-23 08:37:01 +02:00
Jukka Rissanen 8b8178b0f9 drivers: eth: gmac: Do not verify config for unit tests
No need to verify that the configuration is proper if we are
compiling the driver for unit test and not going to ever run
the test.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-03-20 10:37:34 -04:00
Jukka Rissanen 0f66426f4a drivers: eth: Add ethernet driver for native posix arch
This creates zeth network interface in your host and allows user
to send and receive data sent to this network interface.

Fixes #6007

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-03-18 20:47:36 -04:00
Anas Nashif 8949233390 kconfig: fix more help spacing issues
Fix Kconfig help sections and add spacing to be consistent across all
Kconfig file. In a previous run we missed a few.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-02-15 23:20:55 -05:00
Erwin Rol 33525c3e5d drivers: ethernet: eth_stm32_hal: use Kconfig to select HAL/LL sources
Use "select USE_STM32_HAL_ETH" to select the needed STM32 HAL files,
instead of editing ext/hal/st/stm32cube/CMakeLists.txt

Signed-off-by: Erwin Rol <erwin@erwinrol.com>
2018-01-23 08:46:16 -06:00
Jukka Rissanen e63a781612 drivers: eth: mcux: Use correct Kconfig option for RX bufs
The mcux ethernet driver was using TX buf count when allocating
RX buffers.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-01-10 10:32:16 -06:00
Erwan Gouriou 89eb2d2057 drivers: ethernet: stm32: various small changes
Amend stm32 ethernet driver with small changes:
*Provide HAL_ETH_Init return value in error message,
return on error and move it before thread creation
*Provide computed MAC address in debug message

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2018-01-09 08:44:03 -06:00
Paul Sokolovsky 2a795a19ff drivers: eth_mcux: Implement IPv6 multicast group joining/leaving
IPv6 mcast addr to MAC mcast conversion was factored out to
subsys/net/ip/l2/ethernet.c for reuse by other drivers.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-12-12 09:24:51 -05:00
Paul Sokolovsky 81ecfc3506 drivers: eth_mcux: Disable promiscuous mode by default
Now that proper solicited-node multicast group joing is implemented,
promiscuous mode's purpose is reduced to just debugging needs.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-12-11 09:09:48 -05:00
Sebastian Bøe 0829ddfe9a kbuild: Removed KBuild
Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-08 20:00:22 -05:00
Sebastian Bøe 12f8f76165 Introduce cmake-based rewrite of KBuild
Introducing CMake is an important step in a larger effort to make
Zephyr easy to use for application developers working on different
platforms with different development environment needs.

Simplified, this change retains Kconfig as-is, and replaces all
Makefiles with CMakeLists.txt. The DSL-like Make language that KBuild
offers is replaced by a set of CMake extentions. These extentions have
either provided simple one-to-one translations of KBuild features or
introduced new concepts that replace KBuild concepts.

This is a breaking change for existing test infrastructure and build
scripts that are maintained out-of-tree. But for FW itself, no porting
should be necessary.

For users that just want to continue their work with minimal
disruption the following should suffice:

Install CMake 3.8.2+

Port any out-of-tree Makefiles to CMake.

Learn the absolute minimum about the new command line interface:

$ cd samples/hello_world
$ mkdir build && cd build
$ cmake -DBOARD=nrf52_pca10040 ..

$ cd build
$ make

PR: zephyrproject-rtos#4692
docs: http://docs.zephyrproject.org/getting_started/getting_started.html

Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-08 20:00:22 -05:00
Leandro Pereira da9b0ddf5b drivers: Rename random to entropy
This should clear up some of the confusion with random number
generators and drivers that obtain entropy from the hardware.  Also,
many hardware number generators have limited bandwidth, so it's natural
for their output to be only used for seeding a random number generator.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-11-01 08:26:29 -04:00
Leandro Pereira 0dfee8f254 drivers: eth_enc28j60: Check return value of spi_transceive()
Coverity-ID: 178240
Coverity-ID: 178241
Coverity-ID: 178243

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-10-31 18:52:09 -04:00
Jukka Rissanen 29fdc8f956 drivers: eth: mcux: Fix buffer overflow
If we were trying to send max MTU size data, then the temporary
frame_buf was overflowing because it only allocated 1500 bytes
for the buffer but then copied 1514 bytes into it (max mtu +
ethernet header).

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-09-30 13:38:12 -04:00
Paul Sokolovsky db8f470d8d drivers: eth: mcux: Fix error status logging
With logging enabled, this leads to type mismatch warning, which is
promoted to error when building under CI.

Also, reomove extra "\n" from the logging messages.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-09-19 14:09:40 +03:00
Jukka Rissanen c4efc11ffd drivers/eth/mcux: Catch IPv6 multicast group join/leave information
This information will be used to program the chip's receive filter.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-09-13 14:15:02 +03:00
Tomasz Bursztyka b4f88d3982 drivers/ethernet: Fix a packet reception regression in ENC28J60 driver
Commit-id db11fcd174 broke the packet
reception logic in this driver.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-08-30 08:15:41 -04:00
Kumar Gala 74020e5ce0 eth_enc28j60: Update Kconfig dependancy for SPI
The driver uses the SPI legacy API so make it depend on the SPI legacy
API being enabled.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-08-24 10:00:37 -04:00
Leandro Pereira 732424f065 drivers, net: Clean up semaphore initialization
Change the common "init with 0" + "give" idiom to "init with 1".  This
won't change the behavior or performance, but should decrease the size
ever so slightly.

This change has been performed mechanically with the following
Coccinelle script:

    @@
    expression SEM;
    expression LIMIT;
    expression TIMEOUT;
    @@

    - k_sem_init(SEM, 0, LIMIT);
    - k_sem_give(SEM);
    + k_sem_init(SEM, 1, LIMIT);

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-07-27 15:23:07 -04:00
Marti Bolivar bdebff0caa drivers: ethernet: mcux: fix build warning
The ethernet HAL has a different uint32_t typedef than Zephyr's u32_t:
uint32_t in the HAL is long unsigned int, while in Zephyr it's
unsigned int. This is causing a build warning on GCC ("warning:
passing argument 2 of ‘ENET_GetRxFrameSize’ from incompatible pointer
type") when passing a u32_t* where ENET_GetRxFrameSize expects a
uint32_t*.

Add a cast to silence the warning.

Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>
2017-07-26 09:49:45 -05:00
Erwin Rol e3d8a2b34d driver: eth_stm32_hal: make phy address configurable
Signed-off-by: Erwin Rol <erwin@erwinrol.com>
2017-07-12 12:53:51 +03:00
Erwin Rol ad8f83733c driver: eth_stm32_hal: disable hardware multicast filtering
Until Zephyr has infrastructure to enable/disable the
reception of multicast frames we disable the hardware
multicast frame filter completly and pass all multicast
frames to the upper layer and let that deal with them.

Signed-off-by: Erwin Rol <erwin@erwinrol.com>
2017-07-12 12:53:51 +03:00
Erwin Rol 6e3782480e driver: eth_stm32_hal: Initial STM32 HAL based Ethernet driver
Signed-off-by: Erwin Rol <erwin@erwinrol.com>
2017-07-12 12:53:51 +03:00
Anas Nashif 3ec3276163 kconfig: fixed stray Kconfig variables
Those were found using:

  ./scripts/checkconfig.py

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-07-06 10:34:41 -05:00
Anas Nashif 68d7a207ae ethernet: fix Kconfig option for ETHERNET
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-07-05 12:43:13 -04:00
Andrew Boie 2d4a36fc1c drivers: use K_THREAD_STACK_DEFINE macros
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-06-09 18:53:28 -04:00
Paul Sokolovsky 58e8763009 drivers/ethernet/eth_mcux: Fix selection of promisc mode IPv6 workaround
Until we have better solution, we enable promiscuous mode as a
workaround to get IPv6 neighbour discovery going. Kconfig had
typos/thinkos preventing that to work however.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-05-25 15:09:46 -05:00
Paul Sokolovsky 8a3a569cd3 drivers/ethernet/eth_mcux: Fix extra PHY debug Kconfig name.
Source had CONFIG_ETH_MCUX_PHY_DETAILED_DEBUG, while Kconfig had
CONFIG_ETH_MCUX_PHY_EXTRA_DEBUG. Use the shorter name consistently.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-05-24 14:43:02 -05:00
Piotr Mienkowski 36c0fddce7 drivers: eth_sam_gmac: Fix fragment ordering in RX
The data fragments were stored in reversed order when the RX
data was saved into network buffers. This was caused by net_pkt
changes in commit db11fcd "net/net_pkt: Fully separate struct
net_pkt from struct net_buf".

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2017-05-19 23:52:28 +03:00
Andrew Boie 2f9b147058 eth_enc28j60: use k_thread_create()
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-05-11 20:24:22 -04:00
Kumar Gala 4147ad03e3 drivers: eth_dw: Cleanup use of C99 types
We introduced some see C99 types, so convert them over to the Zephyr
types.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-05-09 17:06:28 -04:00
David B. Kinder f930480e16 doc: misspellings in Kconfig files
fix misspelling in Kconfig files that would show up in configuration
documentation and screens.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2017-05-05 19:38:53 -04:00
Leandro Pereira 1c4b09947f drivers: eth_dw: Port to new IP stack
The main difference to how the previous driver operates, is that this
version has zero-copy transmission.  The transmit DMA descriptor is
updated for every fragment that is transmitted from the driver.

Another difference in the transmission path is that this version won't
spin indefinitely while waiting for the DMA transfer to complete; an
arbitrary number of busy checks (20) will be performed, and then
the transmission thread will yield for as long as necessary to finish
the transfer.

These two changes should fix ZEP-472; since that issue was opened for
an older version of Zephyr with uIP, I did not bother going all the way
back to test.

This has been only tested with a Galileo board, using Shared IRQ.

Jira: ZEP-1652
Jira: ZEP-472
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-05-04 11:57:22 -04:00
Jukka Rissanen 7b3148e780 drivers/eth/mcux: Fix the fragment ordering in RX
The data fragments were stored in reversed order when the RX
data was saved into network buffers. This was caused by net_pkt
changes in commit "net/net_pkt: Fully separate struct net_pkt
from struct net_buf".

Change-Id: I8ad2cfc23b2cb90896b0548eab168895b0d7421d
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-28 15:01:09 +03:00
Piotr Mienkowski 65d5e8b2ad drivers: eth_sam_gmac: support reading MAC from I2C EEPROM
This patch adds support for reading MAC address from I2C EEPROM.
Only chips with 7-bit I2C device address are supported.

Change-Id: Ibedc33e54e33bdb901840e104063e2f4752b9123
Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2017-04-28 15:01:08 +03:00
Piotr Mienkowski b996517b5e drivers: eth_sam_gmac: clean up after net_nbuf to net_pkt change
Change-Id: If3aa621b2cc98df4e379dddec6307cbdfb1ed355
Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2017-04-28 15:01:08 +03:00
David B. Kinder 93e4d7258d spell: fix Kconfig help typos: /boards /drivers
Fix misspellings in Kconfig help text

Change-Id: I3ae28a5d23d8e266612114bc0eb8a6e158129dc7
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2017-04-21 21:31:30 +00:00
Kumar Gala a509441210 net: convert to using newly introduced integer sized types
Convert code to use u{8,16,32,64}_t and s{8,16,32,64}_t instead of C99
integer types.

Jira: ZEP-2051

Change-Id: I4ec03eb2183d59ef86ea2c20d956e5d272656837
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-21 09:30:38 -05:00
Tomasz Bursztyka db11fcd174 net/net_pkt: Fully separate struct net_pkt from struct net_buf
- net_pkt becomes a stand-alone structure with network packet meta
  information.
- network packet data is still managed through net_buf, mostly named
  'frag'.
- net_pkt memory management is done through k_mem_slab
- function got introduced or relevantly renamed to target eithe net_pkt
  or net_buf fragments.
- net_buf's sent_list ends up in net_pkt now, and thus helps to save
  memory when TCP is enabled.

Change-Id: Ibd5c17df4f75891dec79db723a4c9fc704eb843d
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-04-21 14:19:50 +03:00
Tomasz Bursztyka bf964cdd4c net: Renaming net nbuf API to net pkt API
There have been long lasting confusion between net_buf and net_nbuf.
While the first is actually a buffer, the second one is not. It's a
network buffer descriptor. More precisely it provides meta data about a
network packet, and holds the chain of buffer fragments made of net_buf.

Thus renaming net_nbuf to net_pkt and all names around it as well
(function, Kconfig option, ..).

Though net_pkt if the new name, it still inherit its logic from net_buf.
'
This patch is the first of a serie that will separate completely net_pkt
from net_buf.

Change-Id: Iecb32d2a0d8f4647692e5328e54b5c35454194cd
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-04-21 14:19:50 +03:00
Kumar Gala 789081673f Introduce new sized integer typedefs
This is a start to move away from the C99 {u}int{8,16,32,64}_t types to
Zephyr defined u{8,16,32,64}_t and s{8,16,32,64}_t.  This allows Zephyr
to define the sized types in a consistent manor across all the
architectures we support and not conflict with what various compilers
and libc might do with regards to the C99 types.

We introduce <zephyr/types.h> as part of this and have it include
<stdint.h> for now until we transition all the code away from the C99
types.

We go with u{8,16,32,64}_t and s{8,16,32,64}_t as there are some
existing variables defined u8 & u16 as well as to be consistent with
Zephyr naming conventions.

Jira: ZEP-2051

Change-Id: I451fed0623b029d65866622e478225dfab2c0ca8
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-20 16:07:08 +00:00