Commit graph

47 commits

Author SHA1 Message Date
Erwan Gouriou 04c1fcfde6 drivers/ethernet: stm32: Get static boot configuration from dts
Update stm32 ethernet driver to get basic boot configuration from
device tree.
So far information are:
- Label
- Base address
- IRQ number and prio
- Clock settings

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-07-24 12:03:33 +02:00
Alexander Kozhinov 92727e9846 drivers: ethernet: stm32: add stm32h7 support
add DTCM caching management in KConfig for stm32h7
add NOCACHE_MEMORY support for stm32h7 M7 CPU series
add HAL_RCC_EX support for stm32h7 series
implemented stm32h7 support within stm32 eth driver

Signed-off-by: Alexander Kozhinov <AlexanderKozhinov@yandex.com>
2020-07-21 15:12:18 +02:00
Alexander Kozhinov ec25fa8592 drivers: ethernet: stm32: pre-add stm32h7 support
added changes that apply to other than stm32h7 series
and prepares stm32h7 series integration:

eth_tx/eth_rx: changed type of total_len
added necessary defines for
    tx_desc and own flag extractions
added read_eth_phy_register() function
    and corresponding defines
added ETH_DMA_MEM and CACHE defines
following memory buffers declarations moved out of
    its ifdef preprocessor macro:
        dma_rx_desc_tab, dma_tx_desc_tab,
        dma_rx_buffer, dma_tx_buffer
added hal_ret stm32 HAL status checks

Signed-off-by: Alexander Kozhinov <AlexanderKozhinov@yandex.com>
2020-07-21 15:12:18 +02:00
Peter Bigot bc34501892 drivers: use macro to define device structures
Replace individual device instance definitions with the macro that
expands to the equivalent change.

    F='struct device DEVICE_NAME_GET'
    git grep -l "$F" \
     | xargs sed -i -r \
       -e "s@$F"'\(([^)]*)\);@DEVICE_DECLARE(\1);@'

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-06-08 15:01:52 -04:00
Kumar Gala a1b77fd589 zephyr: replace zephyr integer types with C99 types
git grep -l 'u\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/u\(8\|16\|32\|64\)_t/uint\1_t/g"
	git grep -l 's\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/s\(8\|16\|32\|64\)_t/int\1_t/g"

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-08 08:23:57 -05:00
Bilal Wasim 190ade91b8 drivers: eth: stm32: Fix invalid assertion comparison
The check for assertion on the "config_func" was added to
validate that the function pointer is valid. However, in
the code we are invoking the "config_func" and comparing
its output with NULL. This causes build failures with
CONFIG_ASSERT=1. Caused by PR-25393.

Tested on Nucleo F767Zi board.

Fixes #25427

Signed-off-by: Bilal Wasim <bilalwasim676@gmail.com>
2020-05-19 14:47:51 +02:00
Bilal Wasim 10a05017bc drivers: eth: stm32: Fix driver crash caused by RX IRQ trigger
All initialization of the Ethernet interface is done in the
eth_initialize function which is invoked by the boot code.
This function sets up DMA, programs the Ethernet module and
enables IRQs. However, this function does not setup "netif"
interface info which is done when the ethernet device is
enumerated by the NET stack via the "iface_api.init" func.
However, after the eth_initialize func is called, it is
possible that the system receives RX interrupts, and the
"rx_thread" accesses the "netif" pointer to get iface info.
However, because the "netif" info is not necessarily
populated at this time, we get a crash (as OS does NULL
access).

Fixed by enabling Ethernet IRQ after the interface is
properly setup.

Tested on Nucleo F767Zi board.

Fixes #25408

Signed-off-by: Bilal Wasim <bilalwasim676@gmail.com>
2020-05-18 19:11:40 +02:00
Martí Bolívar 6e8775ff84 devicetree: remove DT_HAS_NODE_STATUS_OKAY
Several reviewers agreed that DT_HAS_NODE_STATUS_OKAY(...) was an
undesirable API for the following reasons:

- it's inconsistent with the rest of the DT_NODE_HAS_FOO names
- DT_NODE_HAS_FOO_BAR_BAZ(node) was agreed upon as a shorthand
  for macros which are equivalent to
  DT_NODE_HAS_FOO(node) && DT_NODE_HAS_BAR(node) &&
- DT_NODE_HAS_BAZ(node), and DT_HAS_NODE_STATUS_OKAY is an odd duck
- DT_NODE_HAS_STATUS(..., okay) was viewed as more readable anyway
- it is seen as a somewhat aesthetically challenged name

Replace all users with DT_NODE_HAS_STATUS(..., okay), which is
semantically equivalent.

This is mostly done with sed, but a few remaining cases were done by
hand, along with whitespace, docs, and comment changes. These special
cases include the Nordic SOC static assert files.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-05-13 18:24:42 +02:00
Peter Bigot 4f16b419e8 device: avoid casting away const from config_info pointer
The driver-specific config_info structure referenced from the device
structure is marked const.  Some drivers fail to preserve that
qualifier when casting the pointer to the driver-specific structure,
violating MISRA 11.8.

Changes produced by scripts/coccinelle/const_config_info.cocci.

Some changes proposed by the script are not included because they
reveal mutation of state through the const pointer, though the
code works as long as the driver-specific object is defined without
the const qualifier.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-05-13 18:21:52 +02:00
Kumar Gala 8178f76470 drivers: eth: Refactor generation of random mac into help function
Rather than having each driver have its own slightly different way of
generating a random mac address, add a helper function that they all can
call so we do it one way.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-05-09 16:29:57 +02:00
Kumar Gala fdd85d5ad7 dts: Rename DT_HAS_NODE macro to DT_HAS_NODE_STATUS_OKAY
Rename DT_HAS_NODE to DT_HAS_NODE_STATUS_OKAY so the semantics are
clear.  As going forward DT_HAS_NODE will report if a NODE exists
regardless of its status.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-05-06 05:25:41 -05:00
Kumar Gala a49817d17e arm: Convert DT_DTCM_* to new devicetree.h macros
Convert various DT_DTCM_* macros to use DT_CHOSEN(zephyr_dtcm) and
associated macros from devicetree.h.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-26 06:04:46 -05:00
Tomasz Bursztyka 4ae72db135 net: Enable PM settings on network devices
By changing the various *NET_DEVICE* macros. It is up to the device
drivers to either set a proper PM function or, if not supported or PM
disabled, to use device_pm_control_nop relevantly.

All existing macro calls are updated. Since no PM support was added so
far, device_pm_control_nop is used as the default everywhere.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-03-27 14:48:30 +02:00
Jukka Rissanen 36ddeaceca drivers: eth: stm32: Add VLAN support
Add Virtual LAN support to stm32 Ethernet driver. Refactor the
eth_iface_init() and move device configuration settings to
eth_initialize() as the eth_iface_init() is called multiple
times (once / configured VLAN).

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-03-18 12:44:19 +02:00
Jukka Rissanen 330eb0f6f9 drivers: ethernet: stm32: Remove frag debug print in RX
The RX fragment debug print does not work (compile error)
if memory allocation debugging is enabled, so disable it
for time being.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-03-17 13:13:58 +02:00
Peter Bigot 0b0d2e640b treewide: use full path to clock_control/stm32_clock_control.h header
The build infrastructure should not be adding the drivers subdirectory
to the include path.  Fix the legacy uses that depended on that
addition.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-01-26 17:52:12 +01:00
Peter Bigot 6e5db350b2 coccinelle: standardize k_sleep calls with integer timeouts
Re-run with updated script to convert integer literal delay arguments to
k_sleep to use the standard timeout macros.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2019-10-09 08:38:10 -04:00
Markus Fuchs 8c69941642 drivers: ethernet: stm32: Add MAC address configuration support
This patch adds support for configuring the MAC address through the
Network Management API to the STM32 Ethernet driver.

Signed-off-by: Markus Fuchs <markus.fuchs@de.sauter-bc.com>
2019-09-19 20:46:56 -04:00
Erwin Rol c0ae674630 drivers: ethernet: stm32, sam, mcux: correctly set LAA bit
When randomly generating MAC addresses they will always be
locally administrated addresses, so the LAA bit should be set.
The LAA bit is the 2nd bit of the 1st byte of the MAC address
not the 2nd bit of the 4th byte.

Fixes: #16452

Signed-off-by: Erwin Rol <erwin@erwinrol.com>
2019-09-18 19:14:39 +03:00
Markus Fuchs f08caaf677 drivers: ethernet: stm32: Add carrier state detection
This patch adds carrier state detection to the STM32 Ethernet driver.

Fixes #16097

Signed-off-by: Markus Fuchs <markus.fuchs@de.sauter-bc.com>
2019-09-16 15:27:11 -05:00
Alexander Wachter d864f5de5b net: l2: canbus: Add support for canbus Ethernet translator
This commit adds support for a 6LoCAN Ethernet border translator.
CAN frames with the translator CAN address are translated and forwarded
to Ethernet. Ethernet frames with the first 34 bits matching the MAC
address of the translator are translated and forwarded to 6LoCAN.

Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
2019-08-08 13:25:01 +03:00
Alexander Wachter 0fbaaa1350 drivers: ethernet: stm32: Put DMA buffer to DTCM section
For STM32F7 MCU the actual implementation doesn't work when the
DMA buffers are placed in the SRAM.
This might be a problem with caches.
To overcome this problem, the buffer is moved to the DTCM.

Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
2019-07-19 10:05:46 +02:00
Anas Nashif a2fd7d70ec cleanup: include/: move misc/util.h to sys/util.h
move misc/util.h to sys/util.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif 9ab2a56751 cleanup: include/: move misc/printk.h to sys/printk.h
move misc/printk.h to sys/printk.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif 5eb90ec169 cleanup: include/: move misc/__assert.h to sys/__assert.h
move misc/__assert.h to sys/__assert.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif 17ddd1714c cleanup: include/: move clock_control.h to drivers/clock_control.h
move clock_control.h to drivers/clock_control.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Tomasz Bursztyka d6d52ce9e5 net/pkt: Remove _new suffix to net_pkt_write functions
Suffix is now useless, as these functions are now the only ones.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-20 10:27:14 -05:00
Tomasz Bursztyka a25f054cbd net/pkt: Remove _new suffix to net_pkt_read functions
Suffix is now useless, as these functions are now the only ones.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-20 10:27:14 -05:00
Tomasz Bursztyka c14a5c896f drivers/ethernet: Use new net_pkt API for sending and receiving
Use the new API where relevant. Only sam_gmac is left aside for now.

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

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-01 14:34:38 +02:00
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
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
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 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
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 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 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
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
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 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
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
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