Commit graph

478 commits

Author SHA1 Message Date
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
Piotr Mienkowski 323db1e366 drivers: eth_sam_gmac: Make sure not to leak net_buf in RX
Check net_recv_data() return value, if it returns an error release
the net_buf. Based on a fix in eth_mcux driver.

Change-Id: I44ca5fd8dfb7175620b7e8850a68443100039db6
Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2017-04-13 15:21:43 +03:00
Jukka Rissanen 909069d2c7 drivers/eth/mcux: Make sure not to leak net_buf in RX
Check net_recv_data() return value and if it returns an error
then release the net_buf in order to avoid leaking it.

Coverity-CID: 158884

Change-Id: I10d411a2de4b7c7bbe2475df65d93f5b1e619679
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-13 15:21:41 +03:00
Piotr Mienkowski afdb0e0a70 drivers: eth_sam_gmac: Fix initialization order
Atmel SAM family GMAC Ethernet driver is implementing zero-copy
networking. As a result it has to reserve a defined amount of RX
data net buffers before bringing up the interface. Since net buffer
pool is initialized by the network stack and this driver was bringing
the interface up in its initialization function the driver initialization
was performed, as a workaround, after network stack initialization. It
is not a clean solution. This patch fixes this by bringing the
interface up in interface initialization function. The driver itself
can now be initialized before the network stack is.

Tested on Atmel SMART SAM E70 Xplained board

Change-Id: I65886fd6db6f27a10628e393cfabd8e5f78c08ff
Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2017-04-07 12:35:51 +03:00
Piotr Mienkowski 816fdae44d drivers: eth_sam_gmac: remove possible null pointer dereference
Fix eth_tx function which was dereferencing a pointer before
checking that it is not null.

Tested on Atmel SMART SAM E70 Xplained board

Change-Id: Idae4cf9d9a80f6ee9f74a94dd1debe7511c5fab4
Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2017-04-07 12:35:49 +03:00
Maureen Helm aa9c14667b ext: mcux: Update to mcux 2.2 for k64
Updates the mcux drivers and device header files for the k64 from mcux
2.1 to mcux 2.2. Updates the k6x soc init and ethernet shim driver to
reflect mcux interface changes.

Origin: NXP MCUXpresso SDK 2.2
URL: mcux.nxp.com
Maintained-by: External

Change-Id: Icb578dddbe84c190e990b756193bef621010a898
Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2017-03-27 09:05:58 -05:00
Piotr Mienkowski c54b3c7e8f drivers: Update Atmel SAM family GMAC Ethernet driver
Networking stack has split one global DATA pool to RX and TX DATA pools
and also added net_buf pool support to each context. Update the driver
to support this new design. Since the GMAC TX descriptor list has a fixed
size but the number of TX DATA buffers is no longer limited updating the
TX descriptor list has to be guarded by a semaphore.

Tested on Atmel SMART SAM E70 Xplained board

Change-Id: I181e1cdd183e173b85d5d1711b6e78cd5165666d
Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2017-03-17 10:34:44 +02:00
Paul Sokolovsky f1a919187e drivers: eth_enc28j60: Clarify comments in the header file.
Change-Id: Idfac3e6718a2be135e0b4c7f32aad0ddccf18e3c
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-03-13 18:02:34 +03:00
Marcus Shawcroft d261385ed4 eth/mcux: Turn down the PHY debug verbosity.
The PHY debug code is useful while working specifically with the PHY
state machine, but in general the frequent, periodic nature of the
output is a hinderance.  Turn down the verbosity, leave a local define
available for anyone who specifically needs to see the PHY state
machine debug.

Change-Id: I40e59b6df5c29702813d3a554ea9e795a3761c65
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2017-03-09 20:33:47 +02:00
Marcus Shawcroft 43a19bd322 eth/mcux: Fix Kconfig help formatting.
Change-Id: I3d3ff448ca866a2c970d87b4c9f25fc40549c36b
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2017-03-09 20:33:47 +02:00
Juan Manuel Cruz 26b014800b drivers: enc28j60: buffer reception waits timeout
The enc28j60's reception routine requires a timeout
for a buffer assignation. The timeout is configurable
to allow a per application fine tuning.

The effect that K_NO_WAIT currently has is that there are frames
lost everytime that a buffer is required and there are none
available.

Jira: ZEP-1169

Change-Id: Ia18736fd85daee51fe1c2304977209cc7f0038b5
Signed-off-by: Juan Manuel Cruz <juan.m.cruz.alcaraz@intel.com>
2017-03-09 20:33:46 +02:00
Jukka Rissanen 5197266768 net: nbuf: Use net_nbuf_get_frag() to allocate a fragment
The code used net_nbuf_get_reserve_{rx|tx}_data() function to
allocate a fragment. Instead of that low level function, use
net_nbuf_get_frag() instead. There are few places this is not
possible or is too big change like in few test programs.

Change-Id: Ied7e2b7db352de998b200ffa6ff82471bfa5ebe3
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-03-09 20:33:43 +02:00
Jukka Rissanen d32503f57e net: nbuf: Split one global DATA pool to RX and TX DATA pools
If we receive lot of packets, it might happen that we exhaust
all the DATA buffers in the system. This would prevent from
us sending anything to the network.
Change this by splitting the DATA buffer pool into RX and TX
parts. This way RX flooding cannot consume all DATA buffers
that needs to be sent.

Change-Id: I8e8934c6d5fdd47b579ffa6268721b5eb3d64b6d
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-03-09 20:33:43 +02:00
Marcus Shawcroft e82818c59b eth/eth_mcux: Make promiscous mode configurable.
Provide a configuration option for promiscuous mode.

Promiscuous mode provides a convenient workaround for ZEP-1673 however
it generates significant demand for RX buffers on a loaded network.
Add a configuration option to conveniently enable / disable.

The Kconfig defaults promiscuous on to workaroudn 1673, once that
issue is resolved the default logic on NET_IPV6 will be dropped.

Change-Id: I6929aca70d7bd88ce88c65d6654d664ea6653b66
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2017-03-09 20:33:42 +02:00
Marcus Shawcroft e675352e10 eth/eth_mcux: Provide start and stop operations on the PHY driver.
Refactor the PHY state machine and add support for explicit start and
stop.

The stop implementation remains partial, the state machine will enter
a disabled state but will not actual attempt to power down the PHY.
This is deliberate, while implementing this it has become apparent
that issuing a PHY power down command is an effective way of bricking
frdm-k64f boards, hence explicit power down deliberately disabled
until the issue is properly understood.

Change-Id: I846a51b0ac48feed35d260cf20b50f4f1ac59298
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2017-02-27 10:28:55 +02:00
Marcus Shawcroft d9dfd503df eth/eth_mcux: Provide phy state name printing in debug
Change-Id: I07cb7d9958b00b94ed7e7801d6b8c0eb421ce4bf
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2017-02-27 10:28:55 +02:00
Jukka Rissanen 4eb2020055 net: Set the network link address type when setting link address
The interface L2 address type is set at the same time as the
L2 address is set to the network interface. This is most
convinient place to set the address type.

Change-Id: I712d7357d075959eb79df3463141cfbc6d163a74
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-02-22 17:28:25 +02:00
Paul Sokolovsky 5035f97686 eth/mcux: Add temporary workaround to unbreak IPv6 ND features.
This is a workaround for lack of driver API support for multicast
management. So, instead we want to receive all multicast frames
"by default", or otherwise basic IPv6 features, like address
resolution, don't work. On Kinetis Ethernet controller, that
translates to enabling promiscuous mode. The real fix depends
on ZEP-1673.

Change-Id: I98a27584be65bdc405de005383eb30bad2a7fcfc
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-02-14 08:30:35 +02:00
Marcus Shawcroft bbada2de50 eth/mcux: Add basic PHY support.
Add basic PHY management sufficient to detect link up, link down and
auto negotiated link speed / duplex.  The PHY driver is implemented as
a state machine that executed in the system work queue.  The
implementation is non blocking, using the MII interrupt to capture the
completion of read and write events.

This PHY management should be fairly generic. In the future, it may be
beneficial to pull this code out as a standalone PHY driver for use
with other ethernet drivers.

JIRA: ZEP-1674

Change-Id: I3dcb5c14982ef4b40591fcf10d84840b8a2558e5
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2017-02-14 08:30:34 +02:00
Jukka Rissanen bd3908b2a9 net: nbuf: Add timeout to net_buf getters
This commit changes the net_buf getter functions in nbuf.h
by adding a timeout parameter. These function prototypes
are changed to accept a timeout parameter.
	net_nbuf_get_rx()
	net_nbuf_get_tx()
	net_nbuf_get_data()
	net_nbuf_get_reserve_rx()
	net_nbuf_get_reserve_tx()
	net_nbuf_get_reserve_data()
	net_nbuf_copy()
	net_nbuf_copy_all()
	net_nbuf_push()
	net_nbuf_append()
	net_nbuf_write()
	net_nbuf_insert()

Following convinience functions have not been changed
	net_nbuf_append_u8
	net_nbuf_append_be16
	net_nbuf_append_be32
	net_nbuf_insert_u8
	net_nbuf_insert_be16
	net_nbuf_insert_be32
	net_nbuf_write_u8
	net_nbuf_write_be16
	net_nbuf_write_be32
so they call the base function using K_FOREVER. Use the
base function if you want to have a timeout when net_buf
is allocated.

Change-Id: I20bb602ffb73069e5a02668fce60575141586c0f
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-02-08 10:12:35 +02:00
Jukka Rissanen b4ca6e8300 drivers/eth/mcux: Free net_buf using net_nbuf_unref
The driver was using net_buf_unref(). This technically works
ok but debugging the network buffer allocations is more
difficult if done like this.

Change-Id: If3453a49337c7a359c8af22cfdf331fccc697af5
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-02-08 10:12:34 +02:00
Juan Manuel Cruz 35011815f3 drivers: enc28j60: Enables reception of multicast packets
Jira: ZEP-1544

Change-Id: I96a7f9cd40612c1eaebac79845f4a3157a8f7457
Signed-off-by: Juan Manuel Cruz <juan.m.cruz.alcaraz@intel.com>
2017-02-08 10:12:34 +02:00
Sergio Rodriguez 1bbfd3effe driver: ethernet: Fix typo on enc28j60 driver Kconfig
Change-Id: Ie7178db2da5e4de476192516dfb9ff3a5e8f082a
Signed-off-by: Sergio Rodriguez <sergio.sf.rodriguez@intel.com>
2017-02-03 15:59:14 +02:00
Anas Nashif 9f004d9b7c drivers: make ethernet init prio depend on NET_L2_ETHERNET
Change-Id: I5e72e7ba53e65e5ebc2b41fa30b84513fe10c998
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-02-02 14:43:51 +00:00
Piotr Mienkowski d519ef17b7 drivers: Add Atmel SAM family GMAC Ethernet driver
This is a zero-copy networking implementation of Ethernet driver.

Limitations:
- one shot PHY setup, no support for PHY disconnect/reconnect
- no support for devices with DCache enabled due to missing
  non-cacheable RAM regions in Zephyr.

Tested on Atmel SMART SAM E70 Xplained board

Origin: Original

Jira: ZEP-1492
Change-Id: Ib944f91193efbd12c1142b0bcf1f635388bf1b87
Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2017-02-01 21:01:19 +00:00
Flavio Santes 1c21029237 drivers/ethernet: Update default GPIO pin for the ENC28J60 module
All sample applicatons in Zephyr, using the ENC28J60 driver, set
the ETH_ENC28J60_0_GPIO_PIN Kconfig variable to 19.
However, in the Kconfig.enc28j60 file this variable is set to 24.
That default value, 24, was used only during the first iterations
of this driver and never used again.

In this patch, we set the Kconfig variable to 19 and simplify
project configuration files by removing one line.

Change-Id: I3d5fd9da04a3f10845d2a409de56f5b9c235e995
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2017-01-20 16:23:17 +02:00
David B. Kinder ac74d8b652 license: Replace Apache boilerplate with SPDX tag
Replace the existing Apache 2.0 boilerplate header with an SPDX tag
throughout the zephyr code tree. This patch was generated via a
script run over the master branch.

Also updated doc/porting/application.rst that had a dependency on
line numbers in a literal include.

Manually updated subsys/logging/sys_log.c that had a malformed
header in the original file.  Also cleanup several cases that already
had a SPDX tag and we either got a duplicate or missed updating.

Jira: ZEP-1457

Change-Id: I6131a1d4ee0e58f5b938300c2d2fc77d2e69572c
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-01-19 03:50:58 +00:00
Maureen Helm 40f5de5a56 ethernet: Rename ksdk to mcux
Renames the ksdk ethernet shim driver to mcux.

Change-Id: Ief03eabe4ce39be0d0896543c1cb660ff380b439
Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2017-01-12 09:46:26 -06:00
Anas Nashif 3d8e86c12c drivers: eliminate nano/micro kernel usage
Jira: ZEP-1415

Change-Id: I4a009ff57edb799750175aef574a865589f96c14
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-12-21 18:45:02 +00:00
Marcus Shawcroft 6a1632ed26 eth/ksdk: Use k_sem instead of nano_sem
Change-Id: I6b024f6054dede28b74f97102d80ef50f9e45a04
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-12-21 12:58:11 +00:00
Marcus Shawcroft 4ede76a6f9 eth/ksdk: Use k_sem_init() initial count
Remove the existing code that iterates over k_sem_give() and setup the
initial counter directly, take the opportunity to set the maximum count.

Change-Id: Ib91ea263567ff761e4953c142a22a56658efe293
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-12-21 12:58:11 +00:00
Marcus Shawcroft f655da2b5e eth/enc28j60: CONFIG_ETHERNET no longer exists.
Change-Id: Ia011aa0ebbf4834bc068564d01cde3309f28a2a4
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-12-20 13:47:33 +00:00
Marcus Shawcroft 9094fdb8c4 eth/config: Group ethernet driver configuration into one menu.
Change-Id: Ieff568916f2c0428719e3e217ce0ca1ddf2908ff
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-12-20 13:47:32 +00:00
Anas Nashif a9e879e273 logging: move sys_log to subsys/logging
Move logging out of misc/ to its own subsystem. Anything related to
logging and any new logging features or backends could be added here
instead of the generic location in misc/ which is overcrowded with
options that are not related to eachother.

Jira: ZEP-1467
Change-Id: If6a3ea625c3a3562a7a61a0ba5fd7e6ca75518ba
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-12-19 19:58:39 +00:00
Tomasz Bursztyka 4687648a26 drivers: eth_ksdk: Simplifying MAC address generation
The ethernet controller being a freescale one, let's use its OUI. Then
only 3 bytes are needed for generating the rest of the MAC address.

Also, generating the MAC address in the right order.

Change-Id: Id3346ef44f8c24edc2e23dee6ac0581ac58cf4ff
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-16 19:14:55 +01:00
Tomasz Bursztyka 943d55d116 drivers: eth_ksdk: There is a unique L2 driver
Removing useless defines for L2 layer driver.

Change-Id: I53ba6268d8716f293eada29a192fc63324f02523
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-16 19:14:55 +01:00
Tomasz Bursztyka 6480594f0a drivers: eth_ksdk: Theres is no longer 'ETHERNET' Kconfig option
Only NET_L2_ETHERNET now.

Change-Id: Ic9bb3c57e0f91c7eeb53cbbfddab085c723a4a5a
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-16 19:14:55 +01:00
Tomasz Bursztyka c1e52674d7 drivers: enc28j60: Removing useless legacy driver
Left over from old IP stack it seems.

Change-Id: Ic7ce731b8661294125fa0e0e058570aeff7b97cf
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-16 19:14:55 +01:00
Tomasz Bursztyka b94042d93b drivers: enc28j60: Expose RX thread stack size and prio config
Such stack size might vary if debug is enabled or not and depending also
on other factors. Let's do the same for priority as well, putting it to
high prio as default (15 is way too low level).

Change-Id: I16afab33895085bacdef087fe70adeb1ae3ca2ab
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-16 19:14:55 +01:00
Tomasz Bursztyka 214970a3a5 drivers: enc28j60: Add logging
Adding relevant error, debug and informational messages.

Change-Id: I0457395a3ac10164f08b3bab0416b769762c6c5a
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-16 19:14:55 +01:00
Tomasz Bursztyka 3e62dfbc22 drivers: ennc28j60: There is a unique L2 driver
Removing unrelevant defines for L2 layer driver.

Change-Id: Iae0f11291f4c19134228ccd976127e7f0f0b635f
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-16 19:14:54 +01:00
Tomasz Bursztyka c38f1e78eb drivers: enc28j60: Fix one tiny naming issue
ll_len means link layer length, but it's misleading here as ll_len is
the whole net buffer length: reserved ll length + payload length.

Change-Id: If7ec0fc950245d370fa0f82ae1050b05c11c7b90
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-16 19:14:54 +01:00
Tomasz Bursztyka 28255fa014 drivers: enc28j60: Fix a Kconfig comment
s/I2C/SPI obviously

Change-Id: Ia589869694137f5e5302869349a39d090a8fee1d
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-16 19:14:54 +01:00
Tomasz Bursztyka 7d6c50d1d0 drivers: enc28j60: Fix a tiny style issue
Change-Id: I39e9caae812903823ed2cdd7ee6510d5bd633820
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-16 19:14:54 +01:00
Tomasz Bursztyka d882e24002 drivers: ethernet: Enable sys log levels depending on NET_ETHERNET_L2
ETHERNET is a left-over from old and now unavailable IP stack.

Change-Id: I488d9ffcfb1fe3589b522dc2d620873daeb892c8
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-16 19:14:54 +01:00
Tomasz Bursztyka 58c34af329 drivers: ethernet: Push DW specific Kconfig options to its own file
Note: This driver need to be ported to new native IP stack in order to
be available again.

Change-Id: I7825c8679e66f8a1d44d75c9d53e9da207b743af
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-16 19:14:54 +01:00
Tomasz Bursztyka aa2c4ec452 drivers: enc28j60: Let's remove the CRC in the end of the frame
At this point, if the frame was accepted by the controller, it means
that CRC was valid. Thus, there is no reason to get it in the buffer.
Let's just pop it out from controller's memory.

Jira: ZEP-1361

Change-Id: Ic8681c77b0afa30583c7fae281db1a89ff97ed2b
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-16 19:14:54 +01:00
Johan Hedberg 30277538e7 drivers/ethernet: Fix SYS_LOG_DBG format specifier for MAC
The SYS_LOG macros now map to printk by default, and printk doesn't
(currently) support %2.2x, rather %02x needs to be used instead (it
gives the same result).

Change-Id: I0f7a5b7da91afba0c970bce7e2680de40c917bd3
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-12-07 18:45:17 +02:00
Jukka Rissanen 68ea9377e6 net: Make native IP stack the default
As the native IP stack is now the default, there is no need
for corresponding Kconfig option.

Change-Id: I08e4992f540f928a2b7378e8803e634e38725348
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:17 +02:00
Jukka Rissanen 6b43821f20 net: Remove legacy Contiki based uIP stack
This commit removes the legacy Contiki based uIP stack.
The new native IP stack must be used after this commit.

The commit also removes following things:
- legacy cc2520 driver
- legacy ethernet drivers
- legacy IP stack samples

and changes these things:
- disabled tests that only work for legacy IP stack
- select new IP stack by default
- enable random number generator by default as it is needed
  by the new IP stack

Change-Id: I1229f9960a4c6654e9ccc6dac14a7efb9394e45d
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:17 +02:00
Jukka Rissanen f2b7492269 ethernet: Add driver initialization priority to Kconfig
The default kernel init priority is too low. Make this
configurable and set the default priority so that the
ethernet driver is started just before the network stack.

This commit adds generic ethernet priority and changes
currently available ethernet drivers to use it.

Change-Id: If695e52b6dd9ea227f10ba306bb145d72d2312b0
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:17 +02:00
Mahavir Jain e12d73e45e ethernet: enc28j60: use unified kernel interface
Remove legacy kernel interface and use unified APIs

Change-Id: I8e99aa5399707a28a326e8abfa8725079de31be6
Signed-off-by: Mahavir Jain <mjain@marvell.com>
2016-12-02 12:41:17 +02:00
Juan Manuel Cruz 9e36897455 ethernet: enc28j60: fixes an issue caused during an internal rebase.
The original commit:

https://gerrit.zephyrproject.org/r/#/c/6256/

has changed because an internal rebase. Two lines adding an SPI
command are missing.
This commit adds back the missing lines.

Change-Id: I5cbeda73ef1eae5eb98dfa3b7f3086b7438da9a9
Signed-off-by: Juan Manuel Cruz <juan.m.cruz.alcaraz@intel.com>
2016-12-02 12:41:15 +02:00
Jukka Rissanen 0f8be63d8e ethernet: ksdk: Use unified kernel API
Dropping legacy API.

Change-Id: Id3d0b3e4ac7834e78a4d70ee5c99c6998958921e
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:14 +02:00
Flavio Santes 69d9dfb027 net/eth: Fix priority value for the ENC28j60 Ethernet driver
Current value (100) is outside the default values: 0 - 15.

Jira: ZEP-1231

Change-Id: Ib3120b52e6eb3d95b369debd7df541fa2b0dfa6e
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2016-12-02 12:41:04 +02:00
Paul Sokolovsky ad064e1434 eth: ksdk: Protect Ethernet frame buffer operations with IRQ lock.
As there's a single intermediate frame buffer used by both RX and TX
routines, protect operations on it with irq_lock() to avoid possibility
that it will be concurrently modified.

Change-Id: Ibbaf882a15fbb193054dbb13ae848becf9deef3f
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2016-12-02 12:41:01 +02:00
Paul Sokolovsky 8b1769a923 eth: ksdk: Update driver for native IP stack.
This updates driver for Kinetis SDK Ethernet device (used for example
by BOARD=frdm_k64f) to work with native Zephyr IP stack driver model.
The conversion is done based on the template of eth_enc28j60.c.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
Change-Id: Ifb0c7d3f921d663d00a2ded89ecdf2336b6e3783
2016-12-02 12:41:01 +02:00
Sergio Rodriguez 20424d5cc6 enc28j60: Fixes change to proper register bank
The register being set before checking the count of the remaining
packets is incorrect, so this code fixes it by setting the proper
register bank before access

Jira: ZEP-1138

Change-Id: Id49ee8439665ff69786f22e13e0d94a2148e4ae7
Signed-off-by: Sergio Rodriguez <sergio.sf.rodriguez@intel.com>
2016-12-02 12:40:58 +02:00
Juan Manuel Cruz 9f1a656511 enc28j60: Fixes an issue with concurrent tx and rx
The ENC28J60 hardware module does not support concurrent
transmission and reception.
This fix adds a control semaphore to exclude the execution
of both processes.

Applies the equivalent changes to the legacy driver.

Jira: ZEP-1097

Change-Id: I9602195d5a97f8d4bf652753c284d61f192357fe
Signed-off-by: Juan Manuel Cruz <juan.m.cruz.alcaraz@intel.com>
2016-12-02 12:40:58 +02:00
Juan Manuel Cruz d0cf3deb96 enc28j60: Improves interface with native IP stack
Tranmission:  Consider that fragments are no adjacent.

Reception:    Consider receiving data in more than one fragment.

SPI routines: Align SPI fragment size with default buffer fragment
              size (128 bytes) for better performance.

Change-Id: I51fc25d8540c36f3719e617a6f33cdea3f63032c
Signed-off-by: Juan Manuel Cruz <juan.m.cruz.alcaraz@intel.com>
2016-12-02 12:40:58 +02:00
Juan Manuel Cruz 39779184ad enc28j60: Fixes a reception issue for big frames.
Everytime the devices receives a frame with odd length it will
add an extra byte of padding to the reception buffer.

This was causing and issue when receiving frames above 64 bytes
length and with odd length.

This commit pops the extra padding byte everytime the received
frame has an odd length.

The equivalent fix is applied to the legacy driver.

Jira: ZEP-1098

Change-Id: Ib93cbcdcf11f3812961b6702f1b7fa621590aab2
Signed-off-by: Juan Manuel Cruz <juan.m.cruz.alcaraz@intel.com>
2016-12-02 12:40:58 +02:00
Juan Manuel Cruz a8bb46f0ec enc28j60: Fixes an issue reading/writing from spi
When the driver receives or transmits a frames with a length
that is multiple of MAX_BUFFER_LENGTH the last block would be
read/sent twice to spi because a missed calculation on
num_remaining.

The issue is fixed by controling when the remaining bytes are
written/read into the spi device and by setting the spi command
on each spi write/read attempt.

The fix is applied to the legacy driver as well.

Jira: ZEP-1098

Change-Id: Icb2195d74e34dcbcf0c70531da9886ca315bd78b
Signed-off-by: Juan Manuel Cruz <juan.m.cruz.alcaraz@intel.com>
2016-12-02 12:40:58 +02:00
Juan Manuel Cruz f63f2f4b97 enc28j60: The MAX_BUFFER_LENGTH is now declared in header.
The MAX_BUFFER_LENGTH symbols is now declared in the
eth_ecn28j60_priv.h file.

The legacy driver does not need this declaration here anymore.

Change-Id: I396fe92dbf5679c64183e25fa8b8d342c7f30dae
Signed-off-by: Juan Manuel Cruz <juan.m.cruz.alcaraz@intel.com>
2016-12-02 12:40:58 +02:00
Jukka Rissanen a559ad37c2 eth: enc28j60_legacy: Make driver config_info structure const.
Change-Id: Ic3aac209024bd9a6e8456b228705b39e88179b01
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:51 +02:00
Juan Manuel Cruz Alcaraz 8d6206c9be enc28j60: Adapt driver for native IP stack
Jira: ZEP-859

Change-Id: I7a073168a2bfba95291e43b227ffb6bfea1f5692
Signed-off-by: Juan Manuel Cruz Alcaraz <juan.m.cruz.alcaraz@intel.com>
2016-12-02 12:40:50 +02:00
Juan Manuel Cruz 3e1d001f9b enc28j60: Fixes an issue reading/writing long frames from SPI
Jira: ZEP-1302
Change-Id: Ia58d51aee14281aaeb2f8e85fbbf8c250eae8e06
Signed-off-by: Juan Manuel Cruz <juan.m.cruz.alcaraz@intel.com>
2016-11-18 23:19:21 +00:00
Andrew Boie 0b474eef9c kernel: deprecate old init levels
PRIMARY, SECONDARY, NANOKERNEL, MICROKERNEL init levels are now
deprecated.

New init levels introduced: PRE_KERNEL_1, PRE_KERNEL_2, POST_KERNEL
to replace them.

Most existing code has instances of PRIMARY replaced with PRE_KERNEL_1,
SECONDARY with POST_KERNEL as SECONDARY has had a longstanding bug
where the documentation specified SECONDARY ran before the kernel started
up, but actually ran afterwards.

Change-Id: I771bc634e9caf7f17dbf214a270bc9967eed7d32
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-11-09 17:59:44 +00:00
Marcus Shawcroft 670f7328e8 driver/eth_ksdk: Limit name space, add static.
Change-Id: I45bad57f7a120c74c072287963a2c43f081bcea3
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-10-26 20:51:05 +00:00
Marcus Shawcroft ab7a768a18 driver/eth_dw: Limit name space, add static.
Change-Id: If9de0bec8bafb66119e158782cf9618143dc2a52
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-10-26 20:51:05 +00:00
Marcus Shawcroft 741d4751b2 driver/enc28j60: Limit name space, add static.
Change-Id: Ibf03dbb5134df81ca26aebe1e0518f1973789952
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-10-26 20:51:04 +00:00
Marcus Shawcroft 6ae68cc36a drivers/eth_enc28j60: Make driver_api structure const.
Change-Id: I7b479bc1ab5805f83bf880d5db3db8f4fad52e1d
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-10-25 18:45:23 +00:00
Marcus Shawcroft b8f0de0e43 eth: enc28j60: Make driver config_info structure const.
Change-Id: Ib36cc9a2a1e72539196803d4a0bf61453d1a4b25
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-10-20 16:48:46 +00:00
Marcus Shawcroft df4b8d3915 eth: dw: Make driver config_info structure const.
Change-Id: I4b3a86c29c28cee09547973e85ea55489c5cc489
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-10-20 16:48:45 +00:00
Marcus Shawcroft fded21ab45 eth/dw: Move RW objects from device config_info to device driver_data.
Mutable driver state relocated from config_info to driver_info.  This
driver supports PCI enumeration.  We drop code that attempts to update
irq_num based on PCI enumeration because the interrupt found by PCI
enumeration must always be the same as the statically configured IRQ
number.

Change-Id: I5580b0ba95635696a825fe66dbf16259c54d5ba8
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-10-19 12:10:59 +00:00
Marcus Shawcroft 87077727bf eth: Add KSDK ENET driver.
Provide a network driver wrapped around the KSDK ENET and PHY
drivers.

The driver performs one shot PHY setup.  There is no support for PHY
disconnect, reconnect or configuration change.  The PHY setup,
implement via KSDK contains polled code that can block the
initialization thread for a few seconds.

There is no statistics collection for either normal operation or error
behaviour.

Origin: Original

Change-Id: Ia0f2e89a61348ed949976070353e823c178fcb24
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-10-16 09:57:35 +00:00
Marcus Shawcroft ec7d259fa3 eth/enc28j60: Make config_info pointers const.
Preparation for const driver configuration data.

Change-Id: I75e51f396ce9dbe5d9f2339b551c142a5afcbfce
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-10-08 11:40:13 +00:00
Marcus Shawcroft 352ef5f033 eth: Rework LOG_ETHERNET_LEVEL config description.
Generalize the LOG_ETHERNET_LEVEL configuration parameter for use with
multiple ethernet drivers.

Change-Id: I26bc2189c8cf79db19f59e8082caec03b0d9c7b8
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-10-05 11:29:37 +00:00
Kumar Gala 9ec847e608 Revert "rfc: ksdk: Add KSDK ENET driver."
This reverts commit 581e15ced2.

The commit was marked RFC and should not have been merged yet.

Change-Id: Iafd3587f8840e64670c32fa5726ea20ac9c9962a
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2016-09-23 09:07:26 -05:00
Marcus Shawcroft 581e15ced2 rfc: ksdk: Add KSDK ENET driver.
Provide a network driver wrapped around the KSDK ENET and PHY
drivers.

This driver is functional, just.  It is not in a fit state to be merged to master yet.

Origin: Original

Change-Id: Id29e756f33c6c0263926139188c49f9a9c3d5e09
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-09-23 01:54:00 +00:00
Juan Manuel Cruz b97f3f3996 eth: Add full-duplex configuration to ENC28J60
The driver originally gets the full-duplex configuration
from the PHCON1 register and PDPXMD bit as stated by the
ENC298J60 specification document section 2.6 "LED Configuration".
This section trust the board to LEDB connection to signal the
full-duplex configuration.

This commit gets the full-duplex configuration from Kconfig
symbols to allow a proper functionality even when the board
is not connecting LEDB apropriately.

Change-Id: I803958409a611e23e2c3e03f40b412f1695947af
Signed-off-by: Juan Manuel Cruz <juan.m.cruz.alcaraz@intel.com>
2016-09-17 22:43:52 +00:00
Juan Manuel Cruz bb4c1bd82a eth: Initial release to tx semaphore for the ENC28J60 driver.
There is a tx semaphore that controls a single access to the
transmission service. The device is capable to manage a single
transmission call at a time. Multiple requests need to wait
for the resource to be free.

This commit adds the initial release to the tx semaphore.

Jira: ZEP-895

Change-Id: Ic9879cfd15bb1494644b2cf0f4565f7e6a2c1c22
Signed-off-by: Juan Manuel Cruz <juan.m.cruz.alcaraz@intel.com>
2016-09-17 22:43:51 +00:00
Juan Manuel Cruz 8da0bad30a eth: Adjust ENC28J60 MAC configuration.
ENCC28J60 specs section 6.5 "MAC Initialization settings"
state that MACON3(7:5) register configure automatic padding and CRC.
It also states that the configuration 111 and 011 both configure as
all short frames to be zero padded with a valid CRC appended.

Nevertheless, experimentally, there are ocassions when configuring as 111
frames does not have a CRC appended. This frames could be rejected
by the receiver if it is configured to do so.

This commit changes configuration from 111 to 011, which is not
presenting that behavior.

Jira: ZEP-842

Change-Id: I302bb99f7a1f23b298fe0db0245963b640644040
Signed-off-by: Juan Manuel Cruz <juan.m.cruz.alcaraz@intel.com>
2016-09-17 22:43:51 +00:00
Juan Manuel Cruz 77e09abdda ethernet: Enables multicast reception for dw driver
Jira: ZEP-471

Change-Id: Id6a3ecbe31c055ab006abe475650c9871460f671
Signed-off-by: Juan Manuel Cruz <juan.m.cruz.alcaraz@intel.com>
2016-09-01 11:04:14 +00:00
Juan Manuel Cruz Alcaraz 6ec7fd5b42 enc28j60: Correction to ECON1.RXEN bit location
Per spec document, RXEN bit corresponds to bit 2
of the ECON1 register instead of bit 1.

Change-Id: I1bbfd048be248575a558679985ba9daadc43df0e
Signed-off-by: Juan Manuel Cruz Alcaraz <juan.m.cruz.alcaraz@intel.com>
2016-08-17 18:35:11 +00:00
Juan Manuel Cruz Alcaraz a1031ec5a6 enc28j60: rx fiber's stack size is increased
The rx fiber call contiki IP stack functions to register
received frames. This interaction requires more stack memory
in the rx fiber stack to avoid memory corruption.

Change-Id: I106339e7dd1ca9282426adfb54590e34297755b3
Signed-off-by: Juan Manuel Cruz Alcaraz <juan.m.cruz.alcaraz@intel.com>
2016-08-17 18:35:05 +00:00
Juan Manuel Cruz Alcaraz f53214e307 enc28j60: allow simultaneous reception and transmission
SPI bus is a shared resource between tx and rx processes.
The access to it must be synchronized to allow a rx process to
happen even when a tx process is taking place.
ECON1 register must be saved by the rx process and recovered
at the end to ensure that the tx process will continue operating
in the same register bank.

Change-Id: Ie9358bf02bef8ddb5bdf76c8847e998a627e5395
Signed-off-by: Juan Manuel Cruz Alcaraz <juan.m.cruz.alcaraz@intel.com>
2016-08-17 18:34:46 +00:00