Skip to content

Commit 13dcef6

Browse files
authored
Merge pull request #6847 from ARMmbed/feature-emac
Merge feature-emac branch into master
2 parents 1863400 + ff32b28 commit 13dcef6

File tree

212 files changed

+16112
-8615
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

212 files changed

+16112
-8615
lines changed

TESTS/netsocket/connectivity/main.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,18 @@
2727

2828
using namespace utest::v1;
2929

30+
// Avoid creating the interface twice
31+
static NetworkInterface *get_interface()
32+
{
33+
static NetworkInterface *interface = MBED_CONF_APP_OBJECT_CONSTRUCTION;
34+
35+
return interface;
36+
}
37+
3038
// Bringing the network up and down
3139
template <int COUNT>
3240
void test_bring_up_down() {
33-
NetworkInterface* net = MBED_CONF_APP_OBJECT_CONSTRUCTION;
41+
NetworkInterface* net = get_interface();
3442

3543
for (int i = 0; i < COUNT; i++) {
3644
int err = MBED_CONF_APP_CONNECT_STATEMENT;

TESTS/network/emac/README.md

Lines changed: 149 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,163 @@
1-
# Description
1+
# Introduction
22

3-
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.
3+
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.
44

5-
# Configuring CTP echo server
5+
## Configuring the CTP echo server
66

7-
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.
7+
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.
88

9-
# Test cases
9+
## Other configuration options
1010

11-
## EMAC interface initialise
11+
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.
1212

13-
Initializes EMAC interface driver.
13+
## Example commands
1414

15-
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.
15+
### CTP echo server
1616

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

19-
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.
19+
`mbed test --compile -m TARGET -t GCC_ARM -v -n tests-network-emac --app-config TESTS/network/emac/template_mbed_app_echo_server.txt`
2020

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

23-
Sends three CTP unicast messages to the CTP echo server. Verifies that all are replied.
23+
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.
2424

25-
## EMAC interface unicast frame length
25+
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.
26+
27+
The CTP echo server sends a 100-byte long broadcast CTP Ethernet frame every 60 seconds to inform the network of its presence.
28+
29+
### Running tests
30+
31+
You can use the following command to run tests:
32+
33+
`mbed test --compile --run -m TARGET -t GCC_ARM -v -n tests-network-emac --app-config TESTS/network/emac/template_mbed_app.txt`
34+
35+
Replace TARGET with the target device.
36+
37+
## Traces
38+
39+
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.
40+
41+
For example, the `EMAC broadcast` test enables send, input CTP frame, success and failure traces:
42+
43+
`SET_TRACE_LEVEL(TRACE_SEND | TRACE_ETH_FRAMES | TRACE_SUCCESS | TRACE_FAILURE);`
44+
45+
This example trace is about a message sent to broadcast address `ff:ff:ff:ff:ff:ff` that an echo server answers:
46+
47+
```
48+
49+
message sent ff:ff:ff:ff:ff:ff
50+
51+
response: receipt number 24 LENGTH OK DATA OK BROADCAST
52+
53+
```
54+
55+
This example trace is about a message sent to broadcast address `ff:ff:ff:ff:ff:ff` that an echo server does not answer:
56+
57+
```
58+
59+
message sent ff:ff:ff:ff:ff:ff
60+
61+
NO RESPONSE: receipt number 25
62+
63+
```
64+
65+
This example is about input message trace. Message hex dump contains the first 32 bytes of the received Ethernet frame:
66+
67+
```
68+
69+
INP> LEN 100
70+
71+
INP> 000000 ff ff ff ff ff ff ba 42 ed 79 11 8a 90 00
72+
73+
INP> 00000e 00 00 02 00 ba 42 ed 79 11 8a 01 00 01 00
74+
75+
```
76+
77+
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.
78+
79+
## Test cases
80+
81+
### EMAC initialize
82+
83+
The test case initializes the EMAC driver and the test network stack.
84+
85+
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`.
86+
87+
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.
88+
89+
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.
90+
91+
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.
92+
93+
The `emac_if_init()` function of the test case configures and powers up the EMAC.
94+
95+
The configuration steps are:
96+
97+
* Setting the test memory manager for the EMAC.
98+
* Setting the EMAC link input and state callbacks to call the test environment input and state callback handlers.
99+
* Reading and setting the Ethernet MAC address.
100+
101+
### EMAC broadcast
102+
103+
1. Sends three CTP broadcast messages (100 bytes each)
104+
2. Waits for three seconds
105+
3. Sends three CTP broadcast messages (60 bytes each).
106+
4. Listens for the CTP echo server responses.
107+
5. Stores the addresses of the echo servers if replies are received.
108+
109+
The test case passes if there are no responses from the echo server, but further test cases are skipped.
110+
111+
### EMAC unicast
112+
113+
1. Sends three CTP unicast messages (100 bytes each) to the CTP echo server.
114+
2. Verifies that all are replied.
115+
116+
### EMAC unicast frame length
26117

27-
Sends CTP unicast messages with Ethernet message length from 100 bytes to maximum. Verifies that all are replied.
118+
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.
119+
2. Verifies that all are replied.
120+
121+
### EMAC unicast burst
122+
123+
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.
124+
2. Repeats the sending 10 times.
125+
3. Verifies that all are replied.
126+
127+
### EMAC multicast filter
128+
129+
Tests multicast filtering. Multicast filtering is an optional feature for the EMAC. The test does not fail if filtering is not implemented.
130+
131+
The multicast testing requests the CTP echo server to forward the CTP messages to a specified multicast address as the destination address.
132+
133+
Test steps:
134+
135+
1. Using unicast, verify that the echo server responses are received.
136+
2. Set the IPv6 multicast filter address and the echo server reply (forward) address to different values. Check if the echo response is filtered.
137+
3. Set the IPv6 multicast filter address and the echo server reply address to same value. Check that the response is not filtered.
138+
4. Set the IPv4 multicast filter address and the echo server reply address to different values. Check if the response is filtered.
139+
5. Set the IPv4 multicast filter address and the echo server reply address to same value. Check that the response is not filtered.
140+
6. Enable the receiving of all multicasts. Check that the response is not filtered.
141+
142+
### EMAC memory
143+
144+
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:
145+
146+
* The output memory allocations are the ones made by the EMAC in the `link_out()` function called by the network stack (test case).
147+
* The input memory allocations are other memory allocations made by the EMAC.
148+
149+
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.
150+
151+
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.
152+
153+
Test steps:
154+
155+
1. Memory buffer allocations are allowed. Verify that echo server responses are received.
156+
2. Disable input memory buffer allocations. The echo server responses should not be received.
157+
3. Allow memory buffer allocations. Verify that the echo server responses are received.
158+
4. Disable output memory buffer allocations. The echo server responses may or may not be received depending on the EMAC link out implementation.
159+
5. Allow memory buffer allocations. Verify that the echo server responses are received.
160+
6. Disable input and output memory buffer allocations. The echo server responses should not be received.
161+
7. Allow memory buffer allocations. Verify that the echo server responses are received.
162+
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.
28163

0 commit comments

Comments
 (0)