Automotive Ethernet Basics - EthIf
First of all, I would like to ask you a few small questions. Do you know:
-
Do you know what the main function of the EthIf module is?
-
What is the relationship between EthIf and Ethernet controllers, Ethernet transceivers, and Ethernet gateways?
-
What are the common function interfaces of Ethif?
Today, let’s explore and answer these questions together. In order to facilitate everyone's understanding, the following is the topic outline of this article:
text
As we know about the CanIf module, as a CAN transceiver, the unified upper-layer ECU abstraction of the CAN controller allows us to decouple the upper-layer application module of CanIf from the underlying hardware, greatly increasing the portability of the software.
The same is true for automotive Ethernet. The AUTOSAR organization has implemented the software architecture distribution of the automotive Ethernet protocol stack according to the same methodology. Among them, EthIf and CanIf have the same role and status, both of which are to realize the underlying hardware such as Ethernet controller and The upper-layer abstraction of the Ethernet transceiver facilitates decoupling of software and hardware, greatly improving software reusability.
Next, we will explain to you the hierarchical relationship, main functions and common function interfaces of the AUTOSAR EthIf module.
Module hierarchy
According to the AUTOSAR standard document specification, the specific location of the EthIf module in the entire software architecture is described in Figure 1 below:
As shown in the figure above, the following basic conclusions can be drawn:
-
There can be Ethernet controllers from multiple suppliers in an Ethernet protocol stack, and each supplier's controller can be controlled independently without affecting each other;
-
There can be multiple Ethernet controllers from the same supplier, but only the same set of Ethernet controller drivers can be used;
-
The Ethernet drivers from the above three different vendors are part of the standard AUTOSAR MCAL and can be fully decoupled from the underlying hardware;
Ethernet controller relationships
In view of the coexistence of Ethernet controllers from multiple vendors, the AUTOSAR EthIf module implements unified management and implementation based on this situation, which can greatly improve the reuse efficiency of the same driver.
As shown in Figure 2 below, it clearly shows the mapping relationship between the EthIf software module and the Ethernet controller driver under the premise of different Ethernet controllers.
Through analysis, it was found that the following index mapping relationship exists between them. This mapping relationship will ensure that the EthIf module can uniquely and accurately control each controller module. The specific Mapping rules are as follows:
-
The EthIf software module has a globally unique number index for each Ethernet controller within it. The index starts from 0, as shown in the number represented by EthIf_CtrlIdx, which is globally unique;
-
For the same type of Ethernet controller, the corresponding Ethernet driver carries out an index number starting from 0 in its software internal module. As shown in the figure below, there are two Ethernet controllers of the same type, so the index numbers are 0 and 1 respectively. The globally unique index of the EthIf module does not conflict;
-
For different types of Ethernet controllers, the corresponding internal index of the corresponding driver module should also start from 0, regardless of whether other types of Ethernet drivers coexist;
Ethernet transceiver relationships
As shown in Figure 3 below, the Ethernet transceiver and the EthIf module have the following corresponding Mapping relationship, which can be summarized as follows:
-
Ethernet transceivers of the same type can use the same Ethernet transceiver driver (Phy driver for short);
-
Different types of Ethernet transceivers should use different Ethernet transceiver drivers;
As shown in Figure 4 below, comparing the relationship between the Ethernet controller and EthIf, we can also see the index mapping relationship between the Ethernet transceiver and EthIf:
If there are multiple transceivers of the same type in the Ethernet transceiver driver, they should be numbered internally starting from 0 to indicate their uniqueness;
Ethernet Switch relationship
Figure 4 below shows the Index relationship between Ethernet Switch and EthIf:
-
Use the same driver for the same type of Ethernet gateway;
-
Ports within the same Ethernet gateway will also be counted from 0 according to index. Port numbers within different Ethernet gateways are independent of each other and do not interfere with each other;
Module main function
As an abstraction layer for the underlying hardware driver, the EthIf module in the AUTOSAR standard has the following basic functions:
-
Complete the communication initialization function and create basic conditions for data sending and receiving;
-
It has the data sending function and provides interfaces to upper-layer applications to realize the normal sending of data;
-
It has the data receiving function and provides interfaces to upper-layer applications to realize the normal reception of data;
-
It has the underlying Phy Link status change management function and can monitor the status of the underlying Phy in a timely manner;
Next, we will describe the above four basic functions of the EthIf module, so that everyone can further understand the basic working principle of the EthIf module.
Communication initialization function
As shown in Figure 5 below, the necessary prerequisite for establishing communication between EthIf and the underlying driver is described, that is, the Eth controller and Eth transceiver need to be initialized by calling the EthIf_Init function;
As shown in Figure 6 below, the relationship between EthSM, EthIf, Eth, and EthTrcv is described. EthSM implements the initialization of the Ethernet controller by calling the function EthIf_SetControllerMode of the EthIf module . At the same time, the Eth module will determine whether the initialization is successful through the callback function. Flag informs the EthSM module.
Then EthSM will call the function EthIf_SetTransceiverMode of the EthIf module to initialize the Eth transceiver. The Eth transceiver will inform the EthSM module through the callback function whether the initialization is successful;
Data sending function
The data sending function of the EthIf module is divided into two modes, one is Polling mode, and the other is Interrupt mode. Generally speaking, the interrupt mode is preferred to meet the real-time requirements of the system.
Figure 7 below shows the Polling mode. In the Polling mode, you can see that the EthIf_MainfunctionTx function will poll whether the transmission is successful. This is also a typical feature of the Polling mode.
Polling mode
Interrupt mode
Figure 8 below shows the interrupt mode for Ethernet data transmission. Compared with the Polling mode, it can be seen that the EthIf_MainfunctionTx function is not used in the interrupt mode. Instead, the interrupt function of the Eth module is used to confirm whether the transmission is successful.
Data receiving function
Similarly, compared with the data sending function, the data receiving function of the EthIf module can also be divided into Polling mode and interrupt mode. Figure 9 below shows the data receiving Polling mode of the EthIf module.
As shown in Figure 9 below, if the EthIf module data reception adopts Polling mode, then you need to use the EthIf_MainfunctionRx function. In this function, call EthIf_RxIndication to inform the upper layer that the data has been successfully received. Using this mode will greatly reduce the data reception efficiency. Generally , Interrupt mode is used first for reception .
Polling mode
Interrupt mode
Figure 10 below shows the data reception interrupt function of the EthIf module. In this mode, you can see that the Eth module uses the interrupt function to inform the upper layer that the data has been received.
Link status change management function
As shown in Figure 11 below, it is described that in the EthIf_MainfunctionRx function, the Link status of the transceiver is notified to the upper layer application by calling EthTrcv_GetLinkState of the EthTrcv module.
VLAN support
The EthIf module must support the VLAN function. This mode will classify VLAN as a virtual controller. The Ethernet driver and Ethernet transceiver will only target the real controller and transceiver, regardless of the VLAN feature.
If there is no valid VLAN ID set, the virtual controller will represent an untagged VLAN, and the EthIf module will use the Buffer provided by the Eth driver to support the VLAN function.
Wake up support
The EthIf module must be implemented by configuring EthIfWakeUpSupport . At the same time, the premise for Wakeup to be effective is that the underlying Ethernet transceiver (Phy) needs to support the sleep wake-up function .
Commonly used function interfaces
In order to facilitate everyone's debugging, Xiao T summarizes the commonly used functions of the EthIf module as follows: