Commit graph

941 commits

Author SHA1 Message Date
Tomasz Gorochowik 3cd1425b58 net: eth: mgmt: Extend the management interface with a getter
This makes use of the get_config callback added to the Ethernet API.

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

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

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

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

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

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

Coverity-CID: 187063
Fixes #9002

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

Coverity-CID: 187078
Fixes #8989

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

Coverity-CID: 187079
Fixes #8988

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

Coverity-CID: 187080
Fixes #8987

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

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

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

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

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

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

Also make definitions more consistent by converting some

  config FOO
  	<type>
  	prompt "foo"

definitions to a shorter form:

  config FOO
  	<type> "foo"

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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