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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
- 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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>