You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/porting/connectivity/Layer3IP.md
+16-18Lines changed: 16 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -25,7 +25,6 @@ The L3IP interface abstracts network stacks and drivers and easily permits multi
25
25
26
26
The first step in the port is to create a driver class for the cellular device that you can instantiate to control your device. You must derive this class from the `L3IP` class. A network stack (or test framework) uses this API to control your driver.
27
27
28
-
29
28
Class L3IP is entirely abstract - you need to implement about a dozen calls to activate the driver, send and receive packets and perform other control and information functions.
30
29
31
30
There are also callback registration functions for upcalls from the driver - the stack can register callback functions for packet reception and link status changes.
@@ -49,33 +48,35 @@ Steps that the network stack uses to power the L3IP driver:
49
48
1. The network stack might query for the memory buffer align preference from the driver.
50
49
1. The network stack is not required to use the alignment for the memory buffers on link out.
51
50
52
-
### The IP Layer3 memory manager
51
+
### The IP Layer3 memory manager
53
52
54
-
The IP Layer3 memory manager class provides an abstracted memory interface toward memory modules used in different network stacks. For the send and receive paths, data is transferred in memory buffers controlled through an`NetStackMemoryManager` object. The network stack provides L3IP driver with reference to the memory manager before L3IP device powers up.
53
+
The IP Layer3 memory manager class provides an abstracted memory interface toward memory modules used in different network stacks. For the send and receive paths, data is transferred in memory buffers controlled through a`NetStackMemoryManager` object. The network stack provides the L3IP driver with reference to the memory manager before the L3IP device powers up.
55
54
56
55
Memory buffer chains store the data on the memory interface. The data passed in either direction either may be contiguous (a single-buffer chain) or may consist of multiple buffers. You can chain the buffers using a singly linked list.
57
56
58
57
On the output call, the L3IP driver is given ownership of a buffer chain - it must free the chain when it has finished with the data. The data may or may not be contiguous. A driver can express alignment preferences for outgoing data, but the network stack is not required to meet these preferences, so a driver relying on alignment may need a slow path that copies data into an aligned (or contiguous) buffer.
59
58
60
59
For reception, the L3IP driver must allocate memory from the `NetStackMemoryManager` to store the received packets - this is then passed to the link input callback, which frees it. By preference, you should allocate this memory using the pool, but if contiguous memory is necessary, you can allocate it from the heap.
61
60
62
-
### IP Layer3 Interface
61
+
### IP Layer3 interface
63
62
64
63
All Mbed OS connectivity devices should provide an Mbed OS `NetworkInterface` implementation.
65
64
66
-
To create and use an IP Layer3 interface, you need the `L3IPInterface` and `L3IP` classes. Moreover you need an L3IP derived driver class for specific target device. Otherwise the linker error `undefined reference to L3IP::get_default_instance()` stops build process.
65
+
To create and use an IP Layer3 interface, you need the `L3IPInterface` and `L3IP` classes. Moreover, you need an L3IP derived driver class for the specific target device. Otherwise, the linker error `undefined reference to L3IP::get_default_instance()` stops the build process.
This attaches the default network stack (usually LWIP - the other alternative is Nanostack) to the specified L3IP driver and provides all the `NetworkInterface` and `NetworkStack` APIs.
75
76
76
77
Below is an example of a target device driver class that needs to be implemented:
@@ -89,34 +90,33 @@ Below is an example of a target device driver class that needs to be implemented
89
90
{
90
91
return Cellular_driver_L3IP::get_instance();
91
92
}
93
+
```
92
94
93
-
You can find this driver class example in the `mbed-os/TESTS/network/l3ip directory`.
95
+
You can find this driver class example in the `mbed-os/TESTS/network/l3ip` directory.
94
96
95
-
### Being the default Interface
97
+
### Being the default interface
96
98
97
99
In Mbed OS, targets may provide default network interfaces through an automated factory method. You can do this with the following call:
98
100
99
101
NetworkInterface::get_default_instance()
100
102
101
-
This way, you can create an ethernet, Wi-fi, mesh or cellular interface. The interface type depends on the `NETWORK_DEFAULT_INTERFACE_TYPE` value in the JSON configuration. Any interface you create this way is set as the default.
103
+
This way, you can create an ethernet, Wi-Fi, mesh or cellular interface. The interface type depends on the `NETWORK_DEFAULT_INTERFACE_TYPE` value in the JSON configuration. Any interface you create this way is set as the default.
102
104
103
105
IP Layer3 Interface doesn't use `NetworkInterface::get_default_instance`, so it is not set as the default when you create it.
104
106
105
107
To set IP Layer3 as the default interface, you can use a new member of `set_as_default()`. This method is not limited to IP Layer3 and can set any network interface as default.
106
-
107
108
108
109
### Cellular interfaces
109
110
110
111
As a cellular interface, a little more work is necessary - at a minimum, you need to implement the extra configuration calls in `L3IPInterface`. This is because the network stacks and IP Layer3 APIs only relate to the basic data path - they have no knowledge of any other configuration mechanisms and assume they are already set up.
111
112
112
113
To do this, create a C++ class that inherits from both `L3IPInterface` and a base class for the new IP Layer3 cellular interface solution. The `L3IPInterface` is a helper class that implements all the core `NetworkInterface` functionality for you. You then need to implement the extra configuration methods.
113
114
114
-
You don't usually directly expose the `L3IP` driver class of a cellular driver - it is not usually declared as `L3IP::get_default_instance`, but you would pass it to the constructor of your base `L3IPInterface`. This then makes it visible using the `getl3ip` method which provides access to L3IP device driver instance. Method `getl3ip`is a member of `L3IPInterface` class.
115
-
115
+
You don't usually directly expose the `L3IP` driver class of a cellular driver because it is not usually declared as `L3IP::get_default_instance`, but you would pass it to the constructor of your base `L3IPInterface`. This then makes it visible using the `getl3ip` method, which provides access to the L3IP device driver instance. The `getl3ip` method is a member of the `L3IPInterface` class.
116
116
117
117
### OnboardNetworkStack
118
118
119
-
You do not have to memorize the precise details of the `OnboardNetworkStack` API - it provides the mechanism to bind a driver to a stack and the APIs needed to implement a `NetworkInterface`, but `L3IPInterface` handles this.
119
+
You do not have to memorize the precise details of the `OnboardNetworkStack` API. It provides the mechanism to bind a driver to a stack and the APIs needed to implement a `NetworkInterface`, but `L3IPInterface` handles this.
120
120
121
121
### Tuning memory allocations
122
122
@@ -126,12 +126,10 @@ Depending on a driver's use of pool and heap memory and other factors, you might
126
126
127
127
The Mbed OS tree contains Greentea-based tests that exercise the L3IP API directly, along with more general socket tests.
128
128
129
-
For general Greentea information, please see the [Greentea](../tools/greentea-testing-applications.html) documentation.
129
+
For Greentea information, please see the [Greentea](../tools/greentea-testing-applications.html) documentation.
130
130
131
131
Greentea L3IP tests are in the Mbed OS tree under the `TESTS/network/L3IP` directory.
132
132
133
+
The driver should also be tested with both network stacks available in Mbed OS because they use the driver somewhat differently. Do this with the JSON option `nsapi.default-stack` set to `LWIP` and `NANOSTACK`.
133
134
134
-
The driver should also be tested with both network stacks available in Mbed OS, as they use the driver somewhat differently - try with the JSON option `nsapi.default-stack` set to each of `LWIP` and `NANOSTACK`.
135
-
136
-
137
-
Please see the [Network Socket test plan](https://github.com/ARMmbed/mbed-os/blob/master/TESTS/netsocket/README.md) for instructions how to run Mbed OS socket tests.
135
+
Please see the [Network Socket test plan](https://github.com/ARMmbed/mbed-os/blob/master/TESTS/netsocket/README.md) for instructions on how to run Mbed OS socket tests.
0 commit comments