Skip to content

Merge feature-emac branch into master #6847

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 61 commits into from
May 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
0386f73
Networking update: general refactoring, unifying EMAC
kjbracey Aug 15, 2017
1c5bbaf
Insert EMACInterface class
kjbracey Dec 5, 2017
6dffe6e
Remove CellularInterface
kjbracey Dec 5, 2017
74dfe34
Add downcast methods to NetworkInterface
kjbracey Dec 19, 2017
28ff255
Updated greentea network interface configuration files
Jan 8, 2018
0ecf4e4
Move Freescale EMAC driver out of lwIP
kjbracey Jan 15, 2018
9582472
Tell mbed build to ignore old lwIP+EMAC drivers
kjbracey Jan 15, 2018
b222c25
Work around Nuvoton #define EMAC
kjbracey Jan 16, 2018
586a62a
Adjust test configurations for EMAC
kjbracey Jan 31, 2018
2548f18
Restrict client and socket example tests to K64F+K66F
kjbracey Jan 31, 2018
1683ff1
Disable Nanostack border router test
kjbracey Jan 31, 2018
6930c6d
Ignore old EMAC Wifi drivers
kjbracey Jan 31, 2018
d831bcb
Remove Ethernet from NUCLEO_F429ZI test
kjbracey Jan 31, 2018
f584ac3
Connectivity test: don't create interface object twice
kjbracey Feb 1, 2018
bc5d4d1
Created memory manager class to netsocket and updated lwip to use it
Dec 21, 2017
668e082
Updated K64F ethernet driver to use memory manager
Dec 21, 2017
4e10cc0
Updated STM ethernet driver to use emac and memory manager
Dec 21, 2017
4950a99
Move STM EMAC driver out out lwIP
kjbracey Jan 15, 2018
5da3cd9
Added preferred alignment to emac and copy to/from to memory manager
Jan 11, 2018
7ce098a
K64F EMAC: Fix TX error path leaks
kjbracey Jan 12, 2018
ef68eb8
Enabled greentea and mbed-os-example-tls/client/sockets test for STM
Feb 8, 2018
5472a97
EMAC: check link status callback is set
kjbracey Jan 10, 2018
a0d374e
Extend EMAC multicast APIs
kjbracey Jan 11, 2018
3c83c62
Nanostack EMAC implementation
kjbracey Dec 8, 2017
01b4d97
Corrected STM eth driver flagging, memory allocation and thread init
Feb 22, 2018
7aebda7
Emac greentea tests for feature-emac
Feb 16, 2018
c1c69be
Made feature-emac changes to emac greentea tests default code
Mar 2, 2018
d83dec9
Stop drivers checking DEVICE_EMAC
kjbracey Mar 5, 2018
fbd9207
Add extra labels for Freescale & STM EMAC drivers
kjbracey Mar 5, 2018
953f1b6
Add EMAC driver README.md with porting guide
kjbracey Mar 13, 2018
de72090
Changed STM emac driver to loop RX frame reading
Mar 15, 2018
93f8cfe
K64F: Updated the SYSMPU SDK driver
mmahadevan108 Apr 23, 2018
7bc4c0e
K64F, K66F: Update the SYSMPU implementation
mmahadevan108 Apr 23, 2018
82b2a27
Kinetis EMAC: Renamed K64F files to Kinetis
mmahadevan108 Apr 23, 2018
d9a66f1
Updated non-blocking connect changes to EMAC greentea test server
Apr 27, 2018
026af3a
Updated emac greentea tests
May 9, 2018
26f3699
Copy edit README.md
May 9, 2018
89209b6
[M487/NUC472] Support new EMAC feature, built OK
cyliangtw May 4, 2018
401f09c
[M487/NUC472] Support DHCP & TCP sample, also remove legacy emac
cyliangtw May 9, 2018
7bfa362
[M487/NUC472] Fix tx frame length and remove GPL license
cyliangtw May 10, 2018
bad530a
Implementation of unified EMAC driver for Renesas mbed boards
TomoYamanaka May 11, 2018
b7e8400
Added non-blocking DNS functionality to network interface
Apr 20, 2018
1c01f5d
Corrected defects
May 3, 2018
c4424ff
Corrected more defects
May 9, 2018
31b8f73
Changed mutexes, delete and DNS call in callback set
May 15, 2018
e481c5e
Added memory manager set to add_ethernet_interface() of test stack
May 17, 2018
f3ec0da
Add NetworkInterface::get_default_instance()
kjbracey Feb 15, 2018
ede0721
Corrected lwip netif flags to be set before power up
May 16, 2018
162a8c0
add-rtl8195am-feature-emac (#6904)
M-ichae-l May 18, 2018
91531a2
Updated ublox odin greentea test configuration file connect statement
May 18, 2018
0b14f12
EMAC adaption added, updated ODIN drivers to v2.5.0 RC1
May 15, 2018
717abf2
in ODIN emac initialization required before connection
May 15, 2018
91ac835
LPC546XX: Add ENET support
mmahadevan108 Apr 27, 2018
fc0ce8c
Add memory configuration for LPC546XX
mmahadevan108 May 3, 2018
fd2c6ba
Removed EMAC get default instance from EMAC tests
May 17, 2018
97b9980
LPC546XX: Correct Ethernet MAC address write
kjbracey May 18, 2018
7e4eb5c
LPC546XX: Correct Ethernet length calculations
kjbracey May 18, 2018
657ac3f
WIFI_EMAC class renamed to OdinWiFiEMAC, Formatting
May 18, 2018
ce08691
WiFi EMAC class name reflected in WiFi drivers binaries
May 18, 2018
332c6ea
recompiled driver against NetworkInterface changes on latest feature-…
May 21, 2018
ff32b28
Refill example lists - all current Ethernet boards
kjbracey May 23, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion TESTS/netsocket/connectivity/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,18 @@

using namespace utest::v1;

// Avoid creating the interface twice
static NetworkInterface *get_interface()
{
static NetworkInterface *interface = MBED_CONF_APP_OBJECT_CONSTRUCTION;

return interface;
}

// Bringing the network up and down
template <int COUNT>
void test_bring_up_down() {
NetworkInterface* net = MBED_CONF_APP_OBJECT_CONSTRUCTION;
NetworkInterface* net = get_interface();

for (int i = 0; i < COUNT; i++) {
int err = MBED_CONF_APP_CONNECT_STATEMENT;
Expand Down
163 changes: 149 additions & 14 deletions TESTS/network/emac/README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,163 @@
# Description
# Introduction

This document describes how to run EMAC tests. The EMAC test cases are made using Ethernet Configuration Testing Protocol (CTP). To run the tests, one device in the Ethernet segment needs to be configured to be a CTP echo server. The devices running the test cases, use the echo server to forward the CTP Ethernet frames back.
This document describes how to run EMAC tests. The EMAC test cases are made using the Ethernet Configuration Testing Protocol (CTP). To run the tests, you need to configure one device in the Ethernet segment to be a CTP echo server. The devices running the test cases use the echo server to forward the CTP Ethernet frames back.

# Configuring CTP echo server
## Configuring the CTP echo server

A device can be configured to be a CTP echo server by enabling `echo-server` setting in the test environment's application `json` file. When device is configured to be a CTP echo server, it starts to forward CTP messages automatically after power up and will continue forwarding until power down.
To configure a device to be a CTP echo server, you need to enable the `echo-server` setting in the `json` file of the test environment application. When you configure a device to be a CTP echo server, it starts to forward CTP messages automatically when it is on and continues to do so until you switch it off.

# Test cases
## Other configuration options

## EMAC interface initialise
Default configuration files included with tests are configured for ethernet. For Wi-Fi, set `test-ethernet` to 0 and `test-wifi` to 1. You also need to configure Wi-Fi SSID and security options to the configuration file.

Initializes EMAC interface driver.
## Example commands

For WLAN installs test case so that it can intercept incoming Ethernet messages from the WLAN driver. Incoming CTP frames are handed by the test case and other frames are forwarded to the LWIP stack.
### CTP echo server

## EMAC interface broadcast
You can use the following command to a build CTP echo server:

Sends three 100 byte CTP broadcast messages, waits for three seconds and sends three 50 byte CTP broadcast messages. Listens for the CTP echo server responses and stores the addresses of the echo servers if replies are received. The test case will pass if there are no responses from echo server, but further test cases will be skipped.
`mbed test --compile -m TARGET -t GCC_ARM -v -n tests-network-emac --app-config TESTS/network/emac/template_mbed_app_echo_server.txt`

## EMAC interface unicast
Replace TARGET with the target device. After building, flash the binary to the CTP echo server device.

Sends three CTP unicast messages to the CTP echo server. Verifies that all are replied.
You can verify that the CTP echo server has started properly by making a terminal connection to the device, resetting it and verifying that `echo server started successfully` prints on the terminal. You can run host tests when the CTP echo server is running on the Ethernet segment.

## EMAC interface unicast frame length
For Wi-Fi tests, the CTP echo server can also run on the ethernet side as long as the network configuration is such that Ethernet frames are routed between Wi-Fi and Ethernet.

The CTP echo server sends a 100-byte long broadcast CTP Ethernet frame every 60 seconds to inform the network of its presence.

### Running tests

You can use the following command to run tests:

`mbed test --compile --run -m TARGET -t GCC_ARM -v -n tests-network-emac --app-config TESTS/network/emac/template_mbed_app.txt`

Replace TARGET with the target device.

## Traces

Test cases have different trace levels based on how much tracing can be done without affecting the performance of the test case. Configure tracing using `SET\_TRACE\_LEVEL` macro.

For example, the `EMAC broadcast` test enables send, input CTP frame, success and failure traces:

`SET_TRACE_LEVEL(TRACE_SEND | TRACE_ETH_FRAMES | TRACE_SUCCESS | TRACE_FAILURE);`

This example trace is about a message sent to broadcast address `ff:ff:ff:ff:ff:ff` that an echo server answers:

```

message sent ff:ff:ff:ff:ff:ff

response: receipt number 24 LENGTH OK DATA OK BROADCAST

```

This example trace is about a message sent to broadcast address `ff:ff:ff:ff:ff:ff` that an echo server does not answer:

```

message sent ff:ff:ff:ff:ff:ff

NO RESPONSE: receipt number 25

```

This example is about input message trace. Message hex dump contains the first 32 bytes of the received Ethernet frame:

```

INP> LEN 100

INP> 000000 ff ff ff ff ff ff ba 42 ed 79 11 8a 90 00

INP> 00000e 00 00 02 00 ba 42 ed 79 11 8a 01 00 01 00

```

To verify whether the echo server is receiving CTP Ethernet frames, enable `echo-server-trace` option in the echo server configuration file. You can use this for debugging purposes. Do not run performance tests such as `EMAC unicast burst` with tracing enabled because tracing affects the echo server performance.

## Test cases

### EMAC initialize

The test case initializes the EMAC driver and the test network stack.

The EMAC test environment uses the test network stack as the default stack. To enable the stack, set the `nsapi.default-stack` option in the `json` file of the test environment application to value `TEST`.

The test network stack is a bare minimum implementation and has the functionality needed to set up the network interface. The test network stack is defined in the `emac_TestNetworkStack.h` and `emac_TestNetworkStack.cpp` files. The stack uses the test memory manager for the EMAC. The test memory manager is defined in the `emac_TestMemoryManager.h` and `emac_TestMemoryManager.cpp` files. Message buffers sent to the EMAC in `link_out()` are allocated from the buffer pool of the test memory manager. The test memory manager pool allocation unit (buffer size) is 610 bytes.

The initialization test constructs the network interface and connects to it. The test network stack and the EMAC are bound to the network interface using `get_default_instance()` calls to the stack and to the EMAC.

After the construction, the network interface is connected. A connect call triggers a set up call to the test network stack. The set up call triggers a call to `emac_if_init()` function in the EMAC initialization test case.

The `emac_if_init()` function of the test case configures and powers up the EMAC.

The configuration steps are:

* Setting the test memory manager for the EMAC.
* Setting the EMAC link input and state callbacks to call the test environment input and state callback handlers.
* Reading and setting the Ethernet MAC address.

### EMAC broadcast

1. Sends three CTP broadcast messages (100 bytes each)
2. Waits for three seconds
3. Sends three CTP broadcast messages (60 bytes each).
4. Listens for the CTP echo server responses.
5. Stores the addresses of the echo servers if replies are received.

The test case passes if there are no responses from the echo server, but further test cases are skipped.

### EMAC unicast

1. Sends three CTP unicast messages (100 bytes each) to the CTP echo server.
2. Verifies that all are replied.

### EMAC unicast frame length

Sends CTP unicast messages with Ethernet message length from 100 bytes to maximum. Verifies that all are replied.
1. Sends CTP unicast messages with Ethernet message length from 100 bytes to the maximum defined by the MTU of the EMAC with 50 bytes increments.
2. Verifies that all are replied.

### EMAC unicast burst

1. Sends CTP unicast messages with Ethernet message length from 100 bytes to the maximum defined by the MTU of the EMAC with 50 bytes increments.
2. Repeats the sending 10 times.
3. Verifies that all are replied.

### EMAC multicast filter

Tests multicast filtering. Multicast filtering is an optional feature for the EMAC. The test does not fail if filtering is not implemented.

The multicast testing requests the CTP echo server to forward the CTP messages to a specified multicast address as the destination address.

Test steps:

1. Using unicast, verify that the echo server responses are received.
2. Set the IPv6 multicast filter address and the echo server reply (forward) address to different values. Check if the echo response is filtered.
3. Set the IPv6 multicast filter address and the echo server reply address to same value. Check that the response is not filtered.
4. Set the IPv4 multicast filter address and the echo server reply address to different values. Check if the response is filtered.
5. Set the IPv4 multicast filter address and the echo server reply address to same value. Check that the response is not filtered.
6. Enable the receiving of all multicasts. Check that the response is not filtered.

### EMAC memory

Tests memory manager out-of-memory situations. The test case configures the test memory manager to reject memory buffer allocations made by the EMAC. Memory buffer allocations are divided into output and input memory allocations:

* The output memory allocations are the ones made by the EMAC in the `link_out()` function called by the network stack (test case).
* The input memory allocations are other memory allocations made by the EMAC.

Depending on the EMAC implementation, it may or may not allocate memory manager buffers in the link output function. If the memory manager buffers are not allocated, disabling the link output memory allocations in the test does not affect the functionality.

In each test step, the test case sends CTP unicast messages with Ethernet message length from 100 bytes to the maximum defined by the MTU of the EMAC with 50 bytes increments. Memory buffers sent to the EMAC in the `link_out()` function are forced to be non-aligned in this test case.

Test steps:

1. Memory buffer allocations are allowed. Verify that echo server responses are received.
2. Disable input memory buffer allocations. The echo server responses should not be received.
3. Allow memory buffer allocations. Verify that the echo server responses are received.
4. Disable output memory buffer allocations. The echo server responses may or may not be received depending on the EMAC link out implementation.
5. Allow memory buffer allocations. Verify that the echo server responses are received.
6. Disable input and output memory buffer allocations. The echo server responses should not be received.
7. Allow memory buffer allocations. Verify that the echo server responses are received.
8. Allocate memory buffers that are sent to the EMAC in link out from the heap (contiguous memory). Verify that the echo server responses are received.

Loading