Automobile cross-node communication method and device
By extending the DSM function of FastDDS and using PCIe to achieve cross-device node communication, the real-time problem of FastDDS under high load conditions is solved, efficient and simple cross-device communication is achieved, and real-time performance and reliability are improved.
Patent Information
- Application Number
- CN202510683087.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-26
- Publication Date
- 2025-09-12
AI Technical Summary
FastDDS's real-time data transmission performance fluctuates under high load or unstable network conditions, resulting in poor real-time performance. In addition, Shared Memory is only applicable to data transmission within the same device, and cross-device communication is highly complex.
Through the distributed shared memory DSM function extended by FastDDS, PCIe is used to achieve cross-device node communication, and the remote procedure call (RPC) mechanism is used to obtain the DSM red-black tree information of the peer device, directly accessing the peer physical address, avoiding additional protocol conversion and routing management.
It improves the real-time performance of cross-device real-time communication, reduces system complexity and design difficulty, enhances flexibility and scalability, and ensures the reliability and stability of communication.
Smart Images

Figure CN120639829A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of automotive electronic technology, and in particular to a method and device for automotive cross-node communication. Background Art
[0002] The Autosar Adaptive Platform (AP) is an open software platform for automotive electronic systems, designed to support emerging automotive technologies such as autonomous driving and connected cars. Fast DDS (Data Distribution Service) is a high-performance, open-source DDS implementation that provides a real-time data transmission and communication solution. AP uses FastDDS communication middleware for high-performance, real-time data transmission.
[0003] FastDDS supports multiple underlying transport protocols, making it adaptable to different network environments and requirements. FastDDS also provides shared memory support, allowing efficient data sharing between different processes running on the same device. This is very useful for applications that require fast data exchange on the same device.
[0004] Although FastDDS is designed for real-time data transmission, in some cases, especially under high load or unstable network conditions, some performance fluctuations or increased latency may occur. This poses challenges for systems with extremely high real-time requirements, resulting in poor real-time performance.
[0005] Furthermore, Shared Memory is only applicable to data transmission within the same device. This means that if real-time data exchange is required between different devices, other transmission methods must be used, such as TCP (Transmission Control Protocol) or UDP (User Datagram Protocol). TCP provides reliable data transmission and is suitable for scenarios with high data integrity requirements, while UDP provides lower latency and higher throughput, making it suitable for real-time data transmission.
[0006] However, both TCP and UDP introduce additional delays and network overhead. Introducing multiple communication methods also requires additional protocol conversion and routing management, further increasing complexity. Summary of the Invention
[0007] The present invention provides a method and apparatus for automobile cross-node communication, which enables real-time communication across devices, improves real-time performance, and reduces complexity. The specific technical solution is as follows.
[0008] In a first aspect, the present invention provides a method for automobile inter-node communication, which is applied to a local device node in an automobile communicating with a peer device node through a distributed shared memory (DSM) function extended by a fast data distribution service (FastDDS). The method comprises:
[0009] When performing cross-node communication for the first time, obtaining a virtual address to be accessed, wherein the local device node and the opposite device node share memory at both the user layer and the kernel layer;
[0010] Find the target local device file corresponding to the virtual address to be accessed in its own user layer;
[0011] Opening the target local device file, and obtaining DSM red-black tree information corresponding to the target local device file from the kernel layer of the opposite device node through remote procedure call (RPC), wherein the DSM red-black tree information corresponding to the target local device file at least includes: a local physical address corresponding to a target space occupied by the target local device file in a PCIe BAR space of the kernel layer of the local device node;
[0012] The local physical address is used as the opposite physical address, and a corresponding space of the opposite physical address in the PCIe BAR space of the kernel layer of the opposite device node is accessed.
[0013] Optionally, before the step of receiving the virtual address to be accessed, the above-mentioned automobile inter-node communication method further includes:
[0014] Receiving a remote procedure call (RPC) file synchronization creation instruction sent by the peer device node, wherein the file synchronization creation instruction at least includes a file name of a peer device file created by the peer device node;
[0015] Invoke its own DSM interface to create a local device file named with the file name in its own device directory through the DSM channel, allocate free space in its own PCIe BAR space corresponding to the free space allocated by the peer device file to the local device file, obtain a local physical address of the local device file, map the local physical address to its own user layer to obtain a corresponding local virtual address, and associate the local virtual address with the local device file;
[0016] Before sending the RPC file synchronization creation instruction, the peer device node creates a peer device file named with the file name in its own device directory, allocates the free space in the PCIe BAR space of the peer device node to the peer device file, obtains the peer physical address of the peer device file, maps the peer physical address to the user layer of the peer device node to obtain the peer virtual address, and associates the peer virtual address with the peer device file.
[0017] Optionally, the step of obtaining the DSM red-black tree information corresponding to the target local device file from the kernel layer of the opposite device node by remote procedure call (RPC) includes:
[0018] Sending a search instruction to the RPC area in the PCIe BAR space of the opposite device node through the RPC area in the PCIe BAR space of the local device node, wherein the search instruction includes the name of the target local device file, the opposite device node finds the offset of the red-black tree node storing the DSM red-black tree information corresponding to the target local device file according to the name, and writes the offset into the RPC area in the PCIe BAR space of the opposite device node, wherein the PCIe BAR space of the local device node is the same as the PCIe BAR space of the opposite device node and the information is synchronized;
[0019] Receive the interrupt trigger instruction sent by the peer device node, and obtain the offset from the RPC area of its own PCIe BAR space;
[0020] According to the offset, find a red-black tree node corresponding to the offset from the red-black tree of the PCIe BAR space of the peer device node;
[0021] Obtain the DSM red-black tree information corresponding to the target local device file in the found red-black tree node.
[0022] Optionally, after the step of obtaining the DSM red-black tree information corresponding to the target local device file from the kernel layer of the peer device node by remote process access RPC, the above-mentioned automobile cross-node communication method further includes:
[0023] The DSM red-black tree information corresponding to the target local device file is saved in its own file structure.
[0024] Optionally, the DSM red-black tree information corresponding to the target local device file also includes the file size and file information of the target local device file.
[0025] In a second aspect, the present invention provides an automobile inter-node communication device, which is applied to a local device node in an automobile to communicate with a peer device node through a distributed shared memory (DSM) function extended by a fast data distribution service (FastDDS). The device includes:
[0026] an acquisition module, configured to acquire a virtual address to be accessed when cross-node communication is performed for the first time, wherein the local device node and the opposite device node share memory in both the user layer and the kernel layer;
[0027] A search module, configured to search the target local device file corresponding to the virtual address to be accessed in its own user layer;
[0028] an opening module, configured to open the target local device file and obtain, from the kernel layer of the peer device node through remote procedure call (RPC), DSM red-black tree information corresponding to the target local device file, wherein the DSM red-black tree information corresponding to the target local device file at least includes: a local physical address corresponding to a target space occupied by the target local device file in a PCIe BAR space of the kernel layer of the local device node;
[0029] The access module is configured to use the local physical address as the opposite physical address and access the corresponding space of the opposite physical address in the PCIe BAR space of the kernel layer of the opposite device node.
[0030] Optionally, the above-mentioned automobile cross-node communication device further includes:
[0031] a receiving module, configured to receive a remote procedure call (RPC) file synchronization creation instruction sent by the peer device node before receiving the virtual address to be accessed, wherein the file synchronization creation instruction at least includes a file name of the peer device file created by the peer device node;
[0032] an allocation module, configured to call its own DSM interface to create a local device file named with the file name in its own device directory through a DSM channel, allocate free space in its own PCIe BAR space corresponding to the free space allocated by the peer device file to the local device file, obtain a local physical address of the local device file, map the local physical address to its own user layer to obtain a corresponding local virtual address, and associate the local virtual address with the local device file;
[0033] Before sending the RPC file synchronization creation instruction, the peer device node creates a peer device file named with the file name in its own device directory, allocates the free space in the PCIe BAR space of the peer device node to the peer device file, obtains the peer physical address of the peer device file, maps the peer physical address to the user layer of the peer device node to obtain the peer virtual address, and associates the peer virtual address with the peer device file.
[0034] Optionally, the opening module includes:
[0035] a sending submodule, configured to send a search instruction to the RPC area in the PCIe BAR space of the opposite device node through the RPC area in the PCIe BAR space of the local device node, wherein the search instruction includes the name of the target local device file, the opposite device node finds the offset of the red-black tree node storing the DSM red-black tree information corresponding to the target local device file according to the name, and writes the offset into the RPC area in the PCIe BAR space of the opposite device node, wherein the PCIe BAR space of the local device node is the same as the PCIe BAR space of the opposite device node and the information is synchronized;
[0036] An offset acquisition submodule, configured to receive an interrupt trigger instruction sent by the peer device node and acquire the offset from the RPC area of its own PCIe BAR space;
[0037] A search submodule, configured to search, according to the offset, a red-black tree node corresponding to the offset from the red-black tree of the PCIe BAR space of the peer device node;
[0038] The acquisition submodule is used to obtain the DSM red-black tree information corresponding to the target local device file in the found red-black tree node.
[0039] Optionally, the above-mentioned automobile cross-node communication device further includes:
[0040] The saving module is used to save the DSM red-black tree information corresponding to the target local device file into its own file structure after obtaining the DSM red-black tree information corresponding to the target local device file from the kernel layer of the opposite device node through the remote process access RPC.
[0041] Optionally, the DSM red-black tree information corresponding to the target local device file also includes the file size and file information of the target local device file.
[0042] As can be seen from the above content, an embodiment of the present invention provides a method and device for automobile cross-node communication, which is applied to a local device node in a car that communicates with a peer device node through the distributed shared memory DSM function extended by the fast data distribution service FastDDS. When cross-node communication is performed for the first time, a virtual address to be accessed can be obtained, wherein the local device node and the peer device node share memory in both the user layer and the kernel layer; the target local device file corresponding to the virtual address to be accessed is found in its own user layer; the target local device file is opened, and the DSM red-black tree information corresponding to the target local device file is obtained from the kernel layer of the peer device node through remote procedure access (RPC), wherein the DSM red-black tree information corresponding to the target local device file includes at least: the local physical address corresponding to the target space occupied by the target local device file in the high-speed serial computer expansion bus standard base address register (PCIe) BAR space of the kernel layer of the local device node; the local physical address is used as the peer physical address to access the corresponding space of the peer physical address in the PCIe BAR space of the kernel layer of the peer device node. Since the local device node and the peer device node communicate via the DSM function extended by FastDDS, and the PCIe-based DSM has lower latency and higher bandwidth, real-time performance can be improved. Furthermore, after the introduction of the DSM function, when cross-node communication is performed for the first time, it is only necessary to open the target local device file and obtain the DSM red-black tree information corresponding to the target local device file from the kernel layer of the peer device node through remote procedure access (RPC). Then, the local physical address in the DSM red-black tree information is used as the peer physical address, and the corresponding space of the peer physical address in the PCIe BAR space of the kernel layer of the peer device node can be accessed. This eliminates the need for additional protocol conversion and routing management, making cross-node communication very simple and reducing complexity.
[0043] The innovative features of the present invention include:
[0044] 1. In an automotive cross-node communication method and apparatus provided by an embodiment of the present invention, real-time performance can be improved because the local device node and the opposite device node communicate via the DSM function extended by FastDDS. The PCIe-based DSM has lower latency and higher bandwidth. Furthermore, after the DSM function is introduced, when cross-node communication is performed for the first time, it is only necessary to open the target local device file and obtain the DSM red-black tree information corresponding to the target local device file from the kernel layer of the opposite device node via remote procedure access (RPC). The local physical address in the DSM red-black tree information is then used as the opposite physical address. This allows access to the corresponding space of the opposite physical address in the PCIe BAR space of the kernel layer of the opposite device node. This eliminates the need for additional protocol conversion and routing management, making cross-node communication very simple and reducing complexity.
[0045] 2. After the peer device node creates a peer device file in the peer device directory and associates it with a section of free space in the peer PCIe BAR space, it sends an RPC file synchronization creation instruction to the local device node. After receiving the RPC file synchronization creation instruction, the local device node synchronously creates a device file with the same name in its own device directory, and then associates the created device file with a section of free space in the PCIe BAR space corresponding to the free space allocated by the peer device file. In this way, each device file corresponds to a section of memory, so that both the local device node and the peer device node can complete shared memory access by accessing the device file with the same name.
[0046] 3. By sending a search command from the RPC area in its own PCIe BAR space to the RPC area in the PCIe BAR space of the peer device node, the kernel layer of the peer device node retrieves the DSM red-black tree information corresponding to the target local device file via RPC. This enables cross-node communication without the need for additional protocol conversion and routing management, reducing system complexity.
[0047] 4. By saving the DSM red-black tree information corresponding to the target local device file into its own file structure, the next time the DSM red-black tree information corresponding to the target local device file needs to be obtained, it can be directly obtained from its own file structure without having to obtain it from the opposite device node, which greatly reduces the acquisition time and improves efficiency.
[0048] 5. PCIe-based DSM provides the ability to share data in a distributed environment. Using DSM can more easily achieve communication between device nodes and directly access the peer device nodes using shared memory, thereby improving flexibility.
[0049] 6. Since there is no need for additional protocol conversion and routing management, there is no need to maintain protocol conversion and routing management, which greatly reduces maintenance costs. The design of multiple device nodes is no different from the design within the same node, which improves scalability and greatly reduces design difficulty and development workload.
[0050] 7. PCIe has guarantees in many aspects such as hardware design, connector quality, compatibility testing, thermal management and error handling. These can ensure that each device node using PCIe operates stably and reliably in various working environments, ensuring the reliability of cross-node communication in the car.
[0051] Of course, it is not necessary to achieve all of the advantages described above simultaneously in order to implement any product or method of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] To more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are merely some embodiments of the present invention. Those skilled in the art can derive other drawings based on these drawings without inventive effort.
[0053] Figure 1 A schematic flow chart of a method for automobile inter-node communication provided by an embodiment of the present invention;
[0054] Figure 2 A schematic diagram of the supplementary FastDDSDSM architecture provided in an embodiment of the present invention;
[0055] Figure 3 A schematic diagram of the PCIe DSM principle provided in an embodiment of the present invention;
[0056] Figure 4 A schematic diagram of NTB BAR space allocation provided in an embodiment of the present invention;
[0057] Figure 5 A schematic diagram of the underlying structure of the vehicle cross-node communication method provided by an embodiment of the present invention;
[0058] Figure 6 A schematic diagram of the structure of an automobile cross-node communication device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0059] The following will provide a clear and complete description of the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0060] It should be noted that the terms "including" and "having" and any variations thereof in the embodiments of the present invention and the accompanying drawings are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or apparatus comprising a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to the process, method, product, or apparatus.
[0061] The embodiment of the present invention discloses a method and apparatus for automobile cross-node communication, which can perform real-time communication across devices, improve real-time performance, and reduce complexity. The embodiment of the present invention is described in detail below.
[0062] Figure 1 A schematic flow chart of a method for inter-node communication in a vehicle according to an embodiment of the present invention. This method is applied to a local device node in a vehicle communicating with a peer device node using the DSM (Distributed Shared Memory) function extended by Fast DDS (Data Distribution Service).
[0063] The local device node refers to the device that performs data access, and the peer device node refers to the device that receives data access from the local device. The local device node and the peer device node can be the same type of device, such as a car's ZCU (Zonal Control Unit).
[0064] To address the limitation of FastDDS Shared Memory, which only applies to data transmission within the same device, the inventors designed a distributed memory (DSM) mechanism based on PCIe (Peripheral Component Interconnect Express, a high-speed serial computer expansion bus standard). This mechanism, referred to as PCIe DSM, provides the ability to share data in a distributed environment, meaning it can support high-speed communication across multiple devices or nodes. In other words, FastDDS originally lacked DSM functionality, but the inventors' expanded DSM functionality in FastDDS enables cross-node communication.
[0065] Figure 2 For a diagram of the supplementary FastDDSDSM architecture provided by an embodiment of the present invention, see Figure 2 In the prior art, processes A1 and A2 in device A interact through the traditional POSIX SHM (Portable Operating System Interface Shared Memory). In the embodiments of the present invention, a DSM interface is added to the Transport layer of FastDDS and a DSM channel is added to C++Boost Interprocess. This allows process A2 in device A to bypass the traditional POSIX SHM by using the DSM API (Application Programming Interface) to directly interact with the PCIe driver. Data can then be transmitted between process A1 and process B1 in device B through the PCIe driver.
[0066] Among them, C++Boost Interprocess is a module in the Boost library that provides inter-process communication and shared memory operations in C++. Figure 2 The VFS (Virtual File Systems) in the virtual file system is used to find the driver corresponding to the device file. Here, device A can be the local device node, and device B can be the peer device node.
[0067] Continue to see Figure 1 , the method specifically includes the following steps.
[0068] S110: When cross-node communication is performed for the first time, a virtual address to be accessed is obtained, wherein the local device node and the opposite device node share memory in both the user layer and the kernel layer.
[0069] The embodiment of the present invention realizes communication across device nodes by memory sharing, namely PCIe DSM. Figure 3 This is a schematic diagram of the PCIe DSM principle provided in an embodiment of the present invention, see Figure 3 , the local device node and the peer device node are connected using PCIe NTB (Non-Transparent Bridge) ( Figure 3(not marked in the figure), after the connection, the system memory space of the local device node is connected to the system memory space of the opposite device node through the PCI BUS (Peripheral Component Interconnect BUS), so that the local device node allocates PCIe NTB BAR (Base Address Register) space (abbreviated as PCIe BAR or NTBBAR) in its own kernel layer, and the opposite device node allocates PCIe NTB BAR space in its own kernel layer, and then the opposite device node can map the memory of the opposite end to the local end through the PCIe NTB.
[0070] Among them, the NTB BAR space can be divided into multiple parts, such as Figure 3 As shown, the NTB BAR space can be divided into BAR0, BAR1, BAR2, ...
[0071] Figure 4 NTB BAR space allocation diagram provided by the embodiment of the present invention, see Figure 4 BAR0 is used as a bridge for the driver's internal PCIe RPC (Remote Procedure Call) mechanism. It also transmits interrupt-related information and other internal information between the two parties. BAR1 is reserved and unused. The space after BAR2 is used to implement the DSM for data access.
[0072] Specifically, the local device node actually applies for physical memory and fills its own PCIe NTB BAR space. Then, the local device node can access the physical memory applied for by the peer device node through its own PCIe NTB BAR. In this way, memory sharing between the local device node and the peer device node can be achieved at the kernel layer. Then, continue to see Figure 3 Both the local device node and the peer device node can use mmap to map the physical address in their kernel to the virtual address in the device node process memory space in their user layer. This allows memory sharing between the local device node and the peer device node in the user layer. That is, the local device node and the peer device node share memory in both the user layer and the kernel layer.
[0073] In order to realize shared memory access between the local device node and the peer device node, in the embodiment of the present invention, the creation of a device file in the peer device node is used as an example to illustrate. First, a device file is created in the device directory of the peer device node. Then, the created device file is associated with a free space in the PCIe BAR space. At the same time, the same device file is synchronously created in the device directory of the local device node through RPC. Figure 3 The uuid in the DSMSegment is associated with the same free space in the PCIe BAR space of the local device node. This completes the association between DSM segment application and memory. Each process can access shared memory by using the DSM segment. Among them, DSMSegment represents a shared memory segment application. For the DSM API, this is the smallest unit representing shared memory. Therefore, both the local device node and the remote device node can access shared memory by accessing the device file with the same name.
[0074] Specifically, before step S110, the automobile inter-node communication method provided by the embodiment of the present invention further includes:
[0075] Receiving a remote procedure call (RPC) file synchronization creation instruction sent by a peer device node, wherein the file synchronization creation instruction at least includes a file name of a peer device file created by the peer device node;
[0076] Calling its own DSM interface to create a local device file named with the file name in its own device directory through the DSM channel, allocating free space in its own PCIe BAR space corresponding to the free space allocated by the peer device file to the local device file, obtaining a local physical address of the local device file, mapping the local physical address to its own user layer to obtain a corresponding local virtual address, and associating the local virtual address with the local device file;
[0077] Among them, before sending the RPC file synchronization creation instruction, the peer device node creates a peer device file named with the file name in its own device directory, allocates the free space in the PCIe BAR space of the peer device node to the peer device file, obtains the peer physical address of the peer device file, maps the peer physical address to the user layer of the peer device node to obtain the peer virtual address, and associates the peer virtual address with the peer device file.
[0078] Before accessing the shared memory, the peer device node receives a file creation instruction, wherein the file creation instruction at least includes a file name.
[0079] Specifically, the peer device node receiving the file creation instruction may parse the incoming command prompt cmd through a driver ioctl (input / output control) interface of the PCIe driver.
[0080] Figure 5 The schematic diagram of the underlying structure of the vehicle cross-node communication method provided by the embodiment of the present invention is shown in FIG. Figure 5 Both the local and peer device nodes have four file operation interfaces: pci_dsm_open, pci_dsm_ftruncate, pci_dsm_mmap, and pci_dsm_unlink. "open" is used to open a file, "ftruncate" is used to define a function, "mmap" is used to map a file or other object into memory, and "unlink" is used to delete a file. All operations on DSM segments can be performed through these four interfaces.
[0081] Figure 5 In the example, the PCI_DEV_0 files in the local device node and the peer device node are generated after the device nodes at both ends are connected to the PCIe NTB. They are used to assist the pci_dsm_open interface in creating device files. The local device file and the peer device file are named the same, both with uuid(1234).
[0082] After receiving the file creation instruction, the peer device node calls its own DSM interface and uses the PCIe driver to create a peer device file named with the file name in its own device directory through the DSM channel.
[0083] After the peer device file is created, the peer device file size will be set. The PCIe driver will allocate a continuous free space from its own PCIe BAR space to the peer device file based on the peer device file size, obtain the peer physical address of the peer device file, and synchronize it to the local device node.
[0084] Then the peer physical address is mapped to its own user layer to obtain the corresponding peer virtual address, and the peer virtual address is associated with the peer device file.
[0085] At the same time, a local device file with the same name as the peer device file is created in the device directory of the local device node through RPC (Remote Procedure Call Protocol). Specifically, a remote procedure call RPC file synchronization creation instruction is sent to the local device node.
[0086] The local device node receives a remote procedure call (RPC) file synchronization creation instruction sent by the opposite device node, wherein the file synchronization creation instruction at least includes a file name of the opposite device file created by the opposite device node.
[0087] After receiving the file synchronization creation instruction, the local device node calls its own DSM interface to use the PCIe driver to create a local device file named with the file name in its own device directory through the DSM channel.
[0088] After the local device file is created, the local device file size will be set. The PCIe driver will plan a continuous free space corresponding to the free space allocated by the peer device file from its own PCIe BAR space and allocate it to the local device file, thereby obtaining the local physical address of the local device file.
[0089] Then the local physical address is mapped to its own user layer to obtain the corresponding local virtual address, and the local virtual address is associated with the local device file.
[0090] Specifically, the device directory of the device nodes at both ends can be the / dev / directory, the DSM interface for creating device files is the pci_dsm_open interface, the DSM interface for allocating free space and associating virtual addresses with device files is the pci_dsm_ftruncate interface, and the DSM interface for mapping physical addresses to user layers to obtain virtual addresses is the pci_dsm_mmap interface. Figure 3 and Figure 5 shown.
[0091] Moreover, the device files created by both parties in the device directory can be synchronously displayed in the other party's device directory. The other party only needs to open the corresponding device file to access the other party's shared memory at will.
[0092] Therefore, after the opposite device node creates a opposite device file in the opposite device directory and associates it with a section of free space in the opposite PCIe BAR space, it sends an RPC file synchronization creation instruction to the local device node, so that after receiving the RPC file synchronization creation instruction, the local device node synchronously creates a device file with the same name in its own device directory, and then associates the created device file with a section of free space in the PCIe BAR space corresponding to the free space allocated by the opposite device file, so that each device file corresponds to a section of memory, so that both the local device node and the opposite device node can complete shared memory access by accessing the device file with the same name.
[0093] When the local device node needs to access the other party's shared memory, it obtains the virtual address to be accessed sent by the user.
[0094] S120: Find the target local device file corresponding to the virtual address to be accessed in the user layer of the local device.
[0095] Since the local virtual address is associated with the local device file, the target local device file corresponding to the virtual address to be accessed can be found in the user layer of the local device.
[0096] S130: Open the target local device file, and obtain the DSM red-black tree information corresponding to the target local device file from the kernel layer of the opposite device node through remote process access RPC, wherein the DSM red-black tree information corresponding to the target local device file at least includes: the local physical address corresponding to the target space occupied by the target local device file in the high-speed serial computer expansion bus standard base address register PCIe BAR space of the kernel layer of the local device node.
[0097] After the target local device file is found, the target local device file is opened, and the DSM red-black tree information corresponding to the target local device file is obtained from the kernel layer of the opposite device node through the remote procedure call RPC.
[0098] In the above text, each device file corresponds to a free space in the PCIe BAR space, and the physical address, file size, and file information of each device file require a suitable data structure to be stored and searched and applied during mmap or unlink.
[0099] Since DSM Segment is used in cross-node scenarios, the number of device files will be very large, and each node needs to clearly know the information of the device files. Therefore, in the embodiment of the present invention, a very efficient data structure is used to save the information of the device files in a way that takes up as little memory as possible. This data structure is the DSM red-black tree. Figure 5 shown.
[0100] Only one node in a cluster needs to store the DSM red-black tree. This tree can be placed in the node's NTB BAR, making it visible to all nodes. In other words, the device file information of all nodes in the cluster is stored in a single DSM red-black tree. All nodes in the cluster operate on this DSM red-black tree through RPC.
[0101] Continue to see Figure 5, the peer device node saves the DSM red-black tree, which includes a root node. Since the local device file and the peer device file are created synchronously, there are two child nodes under the root node, and each child node has two child nodes. Each child node saves the DSM red-black tree information corresponding to a device file. Figure 5 Specifically, the pci_dsm_ftruncate interface saves the DSM red-black tree information corresponding to the local device file into the DSM red-black tree through RPC.
[0102] The DSM red-black tree information corresponding to the target local device file at least includes: the local physical address corresponding to the target space occupied by the target local device file in the high-speed serial computer expansion bus standard base address register PCIe BAR space of the kernel layer of the local device node. The DSM red-black tree information corresponding to the target local device file may also include the file size and file information of the target local device file, wherein the file information includes at least the virtual address, such as Figure 5 As shown in the figure, the name of the device file uuid is 1234, the virtual address addr is 0x0000_1234, the file size is 4096, and the file information is dev.
[0103] If you want to release the created target local device file, you need to use the pci_dsm_unlink interface to obtain the DSM red-black tree information corresponding to the target local device file stored in the DSM red-black tree through RPC, release the space in the BAR based on the local physical address in the DSM red-black tree information corresponding to the target local device file, and cancel the created target local device file based on the file information.
[0104] It should be noted that, in the embodiments of the present invention, the description is based on the relevant operations of the local device node. The operation mode of the opposite device node is the same and will not be repeated here.
[0105] The above-mentioned step of obtaining the DSM red-black tree information corresponding to the target local device file from the kernel layer of the opposite device node by remote process access RPC may include:
[0106] Sending a search instruction to the RPC area in the PCIe BAR space of the peer device node through the RPC area in its own PCIe BAR space, wherein the search instruction includes the name of the target local device file. The peer device node finds the offset of the red-black tree node storing the DSM red-black tree information corresponding to the target local device file based on the name, and writes the offset into the RPC area in the PCIe BAR space of the peer device node. The PCIe BAR space of the local device node is the same as that of the peer device node, and the information is synchronized;
[0107] Receive the interrupt trigger instruction sent by the peer device node and obtain the offset from the RPC area of its own PCIe BAR space;
[0108] According to the offset, find the red-black tree node corresponding to the offset from the red-black tree of the PCIe BAR space of the peer device node;
[0109] Obtain the DSM red-black tree information corresponding to the target local device file in the found red-black tree node.
[0110] In the embodiment of the present invention, the node storing the DSM red-black tree in the cluster acts as the server of the RPC. All other nodes in the cluster act as the client of the RPC. Figure 5 As shown, in this embodiment of the present invention, the client is the local device node, and the server is the peer device node. Of course, the peer device node can also serve as the client in the same manner, which is not repeated here. Both the client and the server can perform insert operations (pci_rpc_insert_dsm_tree), search operations (pci_rpc_search_dsm_tree), and delete operations (pci_rpc_delete_dsm_tree) on the DSM red-black tree. The dsm tree is the DSM red-black tree.
[0111] Specifically, when the DSM red-black tree needs to be operated, the client only needs to send the corresponding command through the RPC area of BAR0, that is, send the search instruction to the RPC area in the PCIe BAR space of the opposite device node through the RPC area in its own PCIe BAR space, and then send an interrupt trigger instruction to cause the server to generate an interrupt, and the client ends the complete wait.
[0112] The server reads the command from the RPC area, executes the corresponding service program based on the command, and writes the offset of the red-black tree node found in the RPC area of BAR0. It also sends an interrupt trigger instruction to the client. The search instruction includes the name of the target local device file. The peer device node uses the name to find the offset of the red-black tree node that stores the DSM red-black tree information corresponding to the target local device file and writes the offset into the RPC area of the peer device node's PCIe BAR space. The PCIe BAR space of the local device node is identical to that of the peer device node, and the information is synchronized.
[0113] The client receives the interrupt trigger and continues to obtain the offset from the RPC area, then retrieves the red-black tree node information from the corresponding BAR space, thus completing the PCIe RPC process. This is to receive the interrupt trigger instruction sent by the peer device node and obtain the offset from the RPC area in its own PCIe BAR space.
[0114] Since the PCIe BAR space of the local device node is the same as the PCIe BAR space of the opposite device node and the information is synchronized, the red-black tree node corresponding to the offset can be found from the red-black tree of the PCIe BAR space of the opposite device node according to the offset, and the DSM red-black tree information corresponding to the target local device file in the found red-black tree node can be obtained.
[0115] Thus, by sending a search instruction from the RPC area in its own PCIe BAR space to the RPC area in the PCIe BAR space of the peer device node, the DSM red-black tree information corresponding to the target local device file can be retrieved from the kernel layer of the peer device node via RPC. This enables cross-node communication without the need for additional protocol conversion and routing management, reducing system complexity.
[0116] In one implementation, after step S130, the automobile inter-node communication method provided by the embodiment of the present invention further includes:
[0117] Save the DSM red-black tree information corresponding to the target local device file to its own file structure.
[0118] After obtaining the DSM red-black tree information corresponding to the target local device file, the DSM red-black tree information corresponding to the target local device file can be saved in its own file structure.
[0119] In this way, the next time you need to obtain the DSM red-black tree information corresponding to the target local device file, you can directly obtain it from its own file structure without having to obtain it from the peer device node through RPC.
[0120] Specifically, the pci_dsm_mmap interface obtains the DSM red-black tree information corresponding to the target local device file from the file structure. If the file structure does not contain the DSM red-black tree information, it means that the target local device file is created in another node. It is necessary to obtain the DSM red-black tree information corresponding to the target local device file stored in the DSM red-black tree through RPC.
[0121] Therefore, by saving the DSM red-black tree information corresponding to the target local device file into its own file structure, the next time the DSM red-black tree information corresponding to the target local device file needs to be obtained, it can be obtained directly from its own file structure without having to obtain it from the opposite device node, which greatly reduces the acquisition time and improves efficiency.
[0122] S140: Using the local physical address as the peer physical address, access the corresponding space of the peer physical address in the PCIe BAR space of the kernel layer of the peer device node.
[0123] After obtaining the local physical address, it can use it as the peer physical address to access the corresponding space in the PCIe BAR space of the kernel layer of the peer device node, that is, to access the shared memory of the peer device node, thus completing cross-node communication between vehicles.
[0124] Access can be reading data, writing data, or modifying data.
[0125] From the above content, it can be seen that the embodiment of the present invention is applied to a local device node in a car that communicates with a peer device node through the distributed shared memory DSM of the fast data distribution service FastDDS, and can obtain a virtual address to be accessed, wherein the local device node and the peer device node share memory in both the user layer and the kernel layer; find the target local device file corresponding to the virtual address to be accessed in its own user layer; open the target local device file, and obtain the DSM red-black tree information corresponding to the target local device file from the kernel layer of the peer device node through remote process access RPC, wherein the DSM red-black tree information corresponding to the target local device file at least includes: the local physical address corresponding to the target space occupied by the target local device file in the high-speed serial computer expansion bus standard base address register PCIe BAR space of the kernel layer of the local device node; use the local physical address as the peer physical address, and access the corresponding space of the peer physical address in the PCIe BAR space of the kernel layer of the peer device node. Since the local device node and the peer device node communicate through FastDDS's DSM, and PCIe-based DSM has lower latency and higher bandwidth, real-time performance can be improved. Furthermore, after the introduction of DSM, it is only necessary to open the target local device file and obtain the DSM red-black tree information corresponding to the target local device file from the kernel layer of the peer device node through remote process access (RPC). Then, the local physical address in the DSM red-black tree information is used as the peer physical address to access the corresponding space of the peer physical address in the PCIe BAR space of the kernel layer of the peer device node. This eliminates the need for additional protocol conversion and routing management, making cross-node communication very simple and reducing complexity.
[0126] In addition, PCIe-based DSM provides the ability to share data in a distributed environment. Using DSM can more easily achieve communication between device nodes and directly access the peer device nodes using shared memory, thereby improving flexibility.
[0127] In addition, since no additional protocol conversion and routing management are required, there is no need to maintain protocol conversion and routing management, which greatly reduces maintenance costs. The design of multiple device nodes is no different from the design within the same node, which improves scalability and greatly reduces design difficulty and development workload.
[0128] In addition, PCIe has guarantees in many aspects such as hardware design, connector quality, compatibility testing, thermal management and error handling. These can ensure that each device node using PCIe operates stably and reliably in various working environments, ensuring the reliability of cross-node communication in the car.
[0129] Figure 6 A schematic diagram of the structure of a vehicle cross-node communication device provided by an embodiment of the present invention, see Figure 6 The present invention provides an automobile cross-node communication device, which is applied to a local device node in an automobile to communicate with a peer device node through the distributed shared memory (DSM) function extended by the Fast Data Distribution Service (FastDDS). The device includes:
[0130] An acquisition module 601 is configured to acquire a virtual address to be accessed when performing cross-node communication for the first time, wherein the local device node and the opposite device node share memory in both the user layer and the kernel layer;
[0131] A search module 602 is configured to search the target local device file corresponding to the virtual address to be accessed in its own user layer;
[0132] An opening module 603 is configured to open the target local device file and obtain, from the kernel layer of the peer device node via remote procedure call (RPC), DSM red-black tree information corresponding to the target local device file, wherein the DSM red-black tree information corresponding to the target local device file at least includes: a local physical address corresponding to a target space occupied by the target local device file in a PCIe BAR space of the kernel layer of the local device node;
[0133] The access module 604 is configured to use the local physical address as the peer physical address and access a corresponding space of the peer physical address in the PCIe BAR space of the kernel layer of the peer device node.
[0134] In an automobile cross-node communication device provided by an embodiment of the present invention, since the local device node and the opposite device node communicate with each other through the DSM function extended by FastDDS, and the PCIe-based DSM has lower latency and higher bandwidth, real-time performance can be improved. Moreover, after the DSM function is introduced, when cross-node communication is performed for the first time, it is only necessary to open the target local device file and obtain the DSM red-black tree information corresponding to the target local device file from the kernel layer of the opposite device node through remote process access RPC. Then, the local physical address in the DSM red-black tree information is used as the opposite physical address, and the corresponding space of the opposite physical address in the PCIe BAR space of the kernel layer of the opposite device node can be accessed. No additional protocol conversion and routing management are required, making cross-node communication very simple and reducing complexity.
[0135] In one implementation, the above-mentioned automobile cross-node communication device may further include:
[0136] a receiving module, configured to receive a remote procedure call (RPC) file synchronization creation instruction sent by the peer device node before receiving the virtual address to be accessed, wherein the file synchronization creation instruction at least includes a file name of the peer device file created by the peer device node;
[0137] an allocation module, configured to call its own DSM interface to create a local device file named with the file name in its own device directory through a DSM channel, allocate free space in its own PCIe BAR space corresponding to the free space allocated by the peer device file to the local device file, obtain a local physical address of the local device file, map the local physical address to its own user layer to obtain a corresponding local virtual address, and associate the local virtual address with the local device file;
[0138] Before sending the RPC file synchronization creation instruction, the peer device node creates a peer device file named with the file name in its own device directory, allocates the free space in the PCIe BAR space of the peer device node to the peer device file, obtains the peer physical address of the peer device file, maps the peer physical address to the user layer of the peer device node to obtain the peer virtual address, and associates the peer virtual address with the peer device file.
[0139] In one implementation, the opening module 603 may include:
[0140] a sending submodule, configured to send a search instruction to the RPC area in the PCIe BAR space of the opposite device node through the RPC area in the PCIe BAR space of the local device node, wherein the search instruction includes the name of the target local device file, the opposite device node finds the offset of the red-black tree node storing the DSM red-black tree information corresponding to the target local device file according to the name, and writes the offset into the RPC area in the PCIe BAR space of the opposite device node, wherein the PCIe BAR space of the local device node is the same as the PCIe BAR space of the opposite device node and the information is synchronized;
[0141] An offset acquisition submodule, configured to receive an interrupt trigger instruction sent by the peer device node and acquire the offset from the RPC area of its own PCIe BAR space;
[0142] A search submodule, configured to search, according to the offset, a red-black tree node corresponding to the offset from the red-black tree of the PCIe BAR space of the peer device node;
[0143] The acquisition submodule is used to obtain the DSM red-black tree information corresponding to the target local device file in the found red-black tree node.
[0144] In one implementation, the above-mentioned automobile cross-node communication device may further include:
[0145] The saving module is used to save the DSM red-black tree information corresponding to the target local device file into its own file structure after obtaining the DSM red-black tree information corresponding to the target local device file from the kernel layer of the opposite device node through the remote process access RPC.
[0146] Optionally, the DSM red-black tree information corresponding to the target local device file also includes the file size and file information of the target local device file.
[0147] The above device embodiment corresponds to the method embodiment and has the same technical effects as the method embodiment. For detailed description, please refer to the method embodiment. The device embodiment is obtained based on the method embodiment. For detailed description, please refer to the method embodiment part and will not be repeated here.
[0148] Those skilled in the art will appreciate that the accompanying drawings are merely schematic diagrams of an embodiment, and the modules or processes in the accompanying drawings are not necessarily required to implement the present invention.
[0149] Those skilled in the art will appreciate that the modules in the apparatuses of the embodiments may be distributed in the apparatuses of the embodiments as described in the embodiments, or may be located in one or more apparatuses different from the embodiments with corresponding changes. The modules in the above embodiments may be combined into one module or further divided into multiple sub-modules.
[0150] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A vehicle cross-node communication method, characterized in that: A local device node in an automobile communicates with a peer device node through a distributed shared memory (DSM) function extended by a fast data distribution service (FastDDS), the method comprising: When performing cross-node communication for the first time, obtaining a virtual address to be accessed, wherein the local device node and the opposite device node share memory at both the user layer and the kernel layer; Find the target local device file corresponding to the virtual address to be accessed in its own user layer; Opening the target local device file, and obtaining DSM red-black tree information corresponding to the target local device file from the kernel layer of the opposite device node through remote procedure call (RPC), wherein the DSM red-black tree information corresponding to the target local device file at least includes: a local physical address corresponding to a target space occupied by the target local device file in a PCIe BAR space of the kernel layer of the local device node; The local physical address is used as the opposite physical address, and a corresponding space of the opposite physical address in the PCIe BAR space of the kernel layer of the opposite device node is accessed.
2. The automobile inter-node communication method according to claim 1, characterized in that: Before the step of receiving the virtual address to be accessed, the method further includes: Receiving a remote procedure call (RPC) file synchronization creation instruction sent by the peer device node, wherein the file synchronization creation instruction at least includes a file name of a peer device file created by the peer device node; Invoke its own DSM interface to create a local device file named with the file name in its own device directory through the DSM channel, allocate free space in its own PCIe BAR space corresponding to the free space allocated by the peer device file to the local device file, obtain a local physical address of the local device file, map the local physical address to its own user layer to obtain a corresponding local virtual address, and associate the local virtual address with the local device file; Before sending the RPC file synchronization creation instruction, the peer device node creates a peer device file named with the file name in its own device directory, allocates the free space in the PCIe BAR space of the peer device node to the peer device file, obtains the peer physical address of the peer device file, maps the peer physical address to the user layer of the peer device node to obtain the peer virtual address, and associates the peer virtual address with the peer device file.
3. The automobile inter-node communication method according to claim 1, wherein: The step of obtaining the DSM red-black tree information corresponding to the target local device file from the kernel layer of the opposite device node by remote process access RPC includes: Sending a search instruction to the RPC area in the PCIe BAR space of the opposite device node through the RPC area in the PCIe BAR space of the local device node, wherein the search instruction includes the name of the target local device file, the opposite device node finds the offset of the red-black tree node storing the DSM red-black tree information corresponding to the target local device file according to the name, and writes the offset into the RPC area in the PCIe BAR space of the opposite device node, wherein the PCIe BAR space of the local device node is the same as the PCIe BAR space of the opposite device node and the information is synchronized; Receive the interrupt trigger instruction sent by the peer device node, and obtain the offset from the RPC area of its own PCIe BAR space; According to the offset, find a red-black tree node corresponding to the offset from the red-black tree of the PCIe BAR space of the peer device node; Obtain the DSM red-black tree information corresponding to the target local device file in the found red-black tree node.
4. The automobile inter-node communication method according to claim 1, wherein: After the step of acquiring the DSM red-black tree information corresponding to the target local device file from the kernel layer of the peer device node by remote process access RPC, the method further includes: The DSM red-black tree information corresponding to the target local device file is saved in its own file structure.
5. The automobile inter-node communication method according to claim 1, wherein: The DSM red-black tree information corresponding to the target local device file also includes the file size and file information of the target local device file.
6. A vehicle cross-node communication device, characterized in that: A local device node in a car that communicates with a peer device node using a distributed shared memory (DSM) function extended by a fast data distribution service (FastDDS), the device comprising: an acquisition module, configured to acquire a virtual address to be accessed when cross-node communication is performed for the first time, wherein the local device node and the opposite device node share memory in both the user layer and the kernel layer; A search module, configured to search the target local device file corresponding to the virtual address to be accessed in its own user layer; an opening module, configured to open the target local device file and obtain, from the kernel layer of the peer device node through remote procedure call (RPC), DSM red-black tree information corresponding to the target local device file, wherein the DSM red-black tree information corresponding to the target local device file at least includes: a local physical address corresponding to a target space occupied by the target local device file in a PCIe BAR space of the kernel layer of the local device node; The access module is configured to use the local physical address as the opposite physical address and access the corresponding space of the opposite physical address in the PCIe BAR space of the kernel layer of the opposite device node.
7. The automobile inter-node communication device according to claim 6, wherein: The device further comprises: a receiving module, configured to receive a remote procedure call (RPC) file synchronization creation instruction sent by the peer device node before receiving the virtual address to be accessed, wherein the file synchronization creation instruction at least includes a file name of the peer device file created by the peer device node; an allocation module, configured to call its own DSM interface to create a local device file named with the file name in its own device directory through a DSM channel, allocate free space in its own PCIe BAR space corresponding to the free space allocated by the peer device file to the local device file, obtain a local physical address of the local device file, map the local physical address to its own user layer to obtain a corresponding local virtual address, and associate the local virtual address with the local device file; Before sending the RPC file synchronization creation instruction, the peer device node creates a peer device file named with the file name in its own device directory, allocates the free space in the PCIe BAR space of the peer device node to the peer device file, obtains the peer physical address of the peer device file, maps the peer physical address to the user layer of the peer device node to obtain the peer virtual address, and associates the peer virtual address with the peer device file.
8. The automobile inter-node communication device according to claim 6, wherein: The opening module includes: a sending submodule, configured to send a search instruction to the RPC area in the PCIe BAR space of the opposite device node through the RPC area in the PCIe BAR space of the local device node, wherein the search instruction includes the name of the target local device file, the opposite device node finds the offset of the red-black tree node storing the DSM red-black tree information corresponding to the target local device file according to the name, and writes the offset into the RPC area in the PCIe BAR space of the opposite device node, wherein the PCIe BAR space of the local device node is the same as the PCIe BAR space of the opposite device node and the information is synchronized; An offset acquisition submodule, configured to receive an interrupt trigger instruction sent by the peer device node and acquire the offset from the RPC area of its own PCIeBAR space; A search submodule, configured to search, according to the offset, a red-black tree node corresponding to the offset from the red-black tree of the PCIe BAR space of the peer device node; The acquisition submodule is used to obtain the DSM red-black tree information corresponding to the target local device file in the found red-black tree node.
9. The automobile inter-node communication device according to claim 6, wherein: The device further comprises: The saving module is used to save the DSM red-black tree information corresponding to the target local device file into its own file structure after obtaining the DSM red-black tree information corresponding to the target local device file from the kernel layer of the opposite device node through the remote process access RPC.
10. The automobile inter-node communication device according to claim 6, wherein: The DSM red-black tree information corresponding to the target local device file also includes the file size and file information of the target local device file.