Data transmission method and device, electronic equipment and readable storage medium
By implementing direct conversion between CAN and Ethernet protocols through the built-in hardware logic of the switching chip, the problems of high CPU resource consumption and insufficient real-time performance under the software conversion method are solved, thereby improving the bus data transmission efficiency and real-time performance.
Patent Information
- Application Number
- CN202511737030.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-25
- Publication Date
- 2026-02-17
AI Technical Summary
In existing CAN-to-Ethernet solutions, the soft conversion method results in high CPU resource consumption and insufficient real-time performance, failing to meet strict communication performance and real-time requirements, leading to a decrease in bus data transmission efficiency.
By using the built-in hardware logic of the switching chip, protocol parsing, encapsulation, and forwarding can be completed independently, avoiding the intervention of the central processing unit. This enables the determination of the target forwarding scenario and encapsulation method of the controller area network packets, and data transmission is performed through hardware logic.
It improves the efficiency of bus data transmission, reduces latency, meets real-time requirements, and frees up CPU resources for other critical tasks.
Smart Images

Figure CN121547424A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of bus communication technology, and in particular to a data transmission method, apparatus, electronic device, and readable storage medium. Background Technology
[0002] Controller Area Network (CAN) to Ethernet (ETH) technology bridges and converts the CAN bus protocol to the Ethernet protocol, enabling communication between CAN devices and Ethernet devices. In automotive and industrial applications, most CAN to Ethernet solutions currently employ a software-based conversion method. This involves transmitting CAN messages to the Central Processing Unit (CPU), where they are processed and converted using a software protocol stack. The core advantages of this approach are flexibility and cost control, especially in early development stages or systems with limited resources.
[0003] However, the processing latency of software-to-consumer (SoftPC) solutions primarily depends on the efficiency of the software protocol stack and the CPU's processing power. As automotive and industrial systems increasingly demand higher communication performance and real-time capabilities, SoftwarePC solutions cannot meet stringent real-time requirements, leading to slower system response or increased communication jitter. Therefore, existing SoftwarePC solutions suffer from high CPU resource consumption and insufficient real-time performance, resulting in decreased bus data transmission efficiency. Summary of the Invention
[0004] In view of this, embodiments of this application provide at least one data transmission method, apparatus, electronic device, and readable storage medium. Through the hardware logic built into the switching chip, the switching chip can independently complete protocol parsing, encapsulation, and forwarding without the intervention of the central processing unit, thereby improving the transmission efficiency of bus data transmission.
[0005] This application mainly includes the following aspects: In a first aspect, embodiments of this application provide a data transmission method applied to a switching chip, the method comprising: Acquire controller local area network (Controller Area Network) packets and extract the characteristic fields of the controller local area network (Controller Area Network) packets; Based on the characteristic fields of the controller area network (CLAN) packets and the hardware routing table, the target forwarding scenario of the CLAN packets, as well as the encapsulation method and forwarding path corresponding to the target forwarding scenario, are determined. Based on the hardware logic built into the switching chip for the target forwarding scenario, the controller LAN packet is parsed according to the protocol, encapsulated according to the encapsulation method corresponding to the target forwarding scenario, and then sent along the forwarding path corresponding to the target forwarding scenario; wherein, the central processing unit does not participate in the protocol parsing, encapsulation and sending process.
[0006] Secondly, embodiments of this application also provide a data transmission device applied to a switching chip, the data transmission device comprising: The data acquisition module is used to acquire controller local area network (Controller Area Network) packets and extract the characteristic fields of the Controller Area Network (Controller Area Network) packets. The scenario determination module is used to determine the target forwarding scenario of the controller local area network (Controller Area Network) packet, as well as the encapsulation method and forwarding path corresponding to the target forwarding scenario, based on the feature fields of the Controller Area Network (Controller Area Network) packet and the hardware routing table. The protocol conversion module is used to parse the controller LAN packets based on the hardware logic built into the switching chip according to the target forwarding scenario, encapsulate them according to the encapsulation method corresponding to the target forwarding scenario, and send them along the forwarding path corresponding to the target forwarding scenario; wherein, the central processing unit does not participate in the protocol parsing, encapsulation and sending process.
[0007] Thirdly, embodiments of this application also provide an electronic device, including a switching chip and a bus; the switching chip has built-in hardware logic for performing the data transmission method described above; the bus is used to provide a data channel for the switching chip.
[0008] Fourthly, embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when loaded by the hardware logic built into the switching chip, executes the steps of the data transmission method described above.
[0009] This application provides a data transmission method, apparatus, electronic device, and readable storage medium. The method, applied to a switching chip, includes: acquiring a Controller Area Network (CAN) packet and extracting its characteristic fields; determining the target forwarding scenario of the CAN packet, as well as the encapsulation method and forwarding path corresponding to the target forwarding scenario, based on the characteristic fields and a hardware routing table; performing protocol parsing on the CAN packet based on the hardware logic built into the switching chip, encapsulating it according to the encapsulation method corresponding to the target forwarding scenario, and then sending it along the forwarding path corresponding to the target forwarding scenario; wherein the central processing unit (CPU) does not participate in the protocol parsing, encapsulation, and sending process. In this way, through the hardware logic built into the switching chip, the switching chip independently completes protocol parsing, encapsulation, and forwarding without CPU intervention, thereby improving the transmission efficiency of bus data transmission.
[0010] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0011] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0012] Figure 1 A flowchart of a data transmission method provided in an embodiment of this application is shown; Figure 2 A schematic diagram of a controller LAN-to-controller LAN forwarding scenario is shown in an embodiment of this application; Figure 3 A schematic diagram of a controller area network-Ethernet forwarding scenario in an embodiment of this application is shown; Figure 4 A schematic diagram of a controller area network (MAN)-Ethernet-MAN forwarding scenario in an embodiment of this application is shown; Figure 5 This paper shows a functional block diagram of a data transmission device provided in an embodiment of this application; Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of this application is shown. Detailed Implementation
[0013] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. The components of the embodiments of this application described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely represents selected embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.
[0014] To facilitate understanding of this application, the technical solutions provided in this application will be described in detail below with reference to specific embodiments.
[0015] Please see Figure 1 , Figure 1 This is a flowchart illustrating a data transmission method provided in an embodiment of this application. Figure 1 As shown in the embodiments of this application, the data transmission method is applied to a switching chip and includes the following steps: S101, Obtain the controller local area network (LAN) message and extract the characteristic fields of the LAN message.
[0016] Here, the switch chip is an application-specific integrated circuit (ASIC) or a field-programmable gate array (FPGA) used to implement high-speed packet forwarding and switching at the data link layer (Layer 2) or network layer (Layer 3). It integrates multiple Ethernet media access controllers (MACs), forwarding engines, lookup tables, buffers, and management interfaces, enabling rapid forwarding of data frames between different ports based on destination addresses. It performs protocol processing and message conversion for CAN and Ethernet without relying on a central processing unit (CPU) for packet-by-packet processing, completely offloading CPU resources. This not only improves the overall system performance but also frees up CPU resources for other critical tasks.
[0017] In this application, the switching chip not only supports traditional Ethernet ports, but also integrates a CAN controller, a hardware parsing layer, a ternary content-addressable memory (TCAM), a direct memory access (DMA) engine, and a time-sensitive networking (TSN) and audio video transport protocol (AVTP) encapsulation engine. This enables low-latency protocol conversion and data forwarding between CAN and Ethernet within the same chip, without requiring CPU involvement in protocol processing. Furthermore, it achieves precise timing control and message synchronization of CAN and Ethernet protocols through hardware logic, thereby providing higher quality communication assurance in complex multi-device communication scenarios.
[0018] In this embodiment, after the switching chip receives the controller local area network (CAN) message through the CAN controller, it first enters the hardware parsing layer and extracts the CAN frame identifier (11-bit / 29-bit ID) and the first 4 bytes of the data field as the feature fields of the CAN message.
[0019] Furthermore, the switching chip employs a dual-port RAM caching mechanism, initiating parallel parsing upon physical layer reception, thus avoiding the latency caused by the software protocol stack and CPU scheduling in software-to-hardware conversion schemes. This makes the hardware conversion scheme perform better in scenarios with high real-time requirements. Specifically, as soon as the switching chip receives the CAN differential signal at the physical layer, it immediately writes the original bit stream to two independent ports of the dual-port RAM simultaneously—port A continues to receive subsequent bit streams, while port B initiates the hardware parsing layer to extract key fields such as identifiers within the same clock cycle. Because the read and write ports are separate and work in parallel, there is no need to wait for the entire frame to be received before handing it over to the software protocol stack for parsing, thereby eliminating the entire latency of "received → interrupt → CPU read → software parsing" and achieving zero-wait parallel parsing.
[0020] S102, based on the characteristic fields of the controller local area network (CLAN) packet and the hardware routing table, determine the target forwarding scenario of the CLAN packet, as well as the encapsulation method and forwarding path corresponding to the target forwarding scenario.
[0021] Here, in the current hybrid network architecture where multiple protocols coexist, communication between CAN nodes in different domains will result in different target forwarding scenarios through the CAN-ETH-ETH-CAN communication path. This embodiment of the application receives CAN messages via a switching chip, directly identifies the characteristic fields in the messages through hardware parsing, and determines the target forwarding scenario of the CAN message, as well as the corresponding encapsulation method and forwarding path, based on the protocol conversion rules (preset state machine) and a lookup table from the hardware routing table.
[0022] S103, based on the hardware logic built into the switching chip for the target forwarding scenario, the controller LAN packet is parsed according to the protocol, encapsulated according to the encapsulation method corresponding to the target forwarding scenario, and sent along the forwarding path corresponding to the target forwarding scenario; wherein, the central processing unit does not participate in the protocol parsing, encapsulation and sending process.
[0023] Here, the hardware logic built into the switching chip performs protocol parsing on the controller LAN packets according to the different target forwarding scenarios, encapsulates them into different data packets according to the encapsulation method corresponding to the target forwarding scenario, and sends them out along the forwarding path corresponding to the target forwarding scenario. This process is completely driven by hardware and does not require CPU intervention.
[0024] Further, determining the target forwarding scenario of the controller LAN packet, and the encapsulation method and forwarding path corresponding to the target forwarding scenario, based on the characteristic fields of the controller LAN packet and the hardware routing table, includes: Step a1: Use a bitmask to perform domain division on the identifier in the feature field to obtain the domain identifier of the controller LAN packet.
[0025] Here, in this embodiment of the application, a routing decision engine is constructed by establishing a three-order decision tree. The first level quickly matches the domain identifier (Router ID) (e.g., ID[28:24] defines the domain identifier) through a bit mask. The identifier in the feature field is divided into domains using a bit mask to obtain the domain identifier of the controller LAN packet.
[0026] Step a2: The domain identifier is compared in parallel with the entries in the tri-state content addressing memory to obtain the matching entries of the domain identifier; the matching entries include the target forwarding scenario, encapsulation method and output port information of the controller LAN packet corresponding to the domain identifier.
[0027] Here, the second level determines the matching entry for the domain identifier by searching the routing table. Specifically, the domain identifier is compared in parallel with the entries in the tri-state content-addressable memory to obtain the matching entry for the domain identifier; the matching entry includes the target forwarding scenario, encapsulation method, and output port information of the controller LAN packet corresponding to the domain identifier. In this embodiment, the routing table is a hardware TCAM table, supporting 16K entries, with a lookup time of <100ns.
[0028] Step a3: Based on the matching entries of the domain identifier, determine the target forwarding scenario of the controller LAN packet, as well as the encapsulation method and forwarding path corresponding to the target forwarding scenario.
[0029] Here, the third level determines the scenario type based on the protocol conversion rules (preset state machine). Specifically, based on the matching entries of the domain identifier, it determines the target forwarding scenario of the controller LAN packet, as well as the encapsulation method and forwarding path corresponding to the target forwarding scenario.
[0030] Furthermore, the target forwarding scenarios include Controller Area Network (CAN) to CAN forwarding scenarios, CAN to Ethernet forwarding scenarios, and CAN to Ethernet to CAN forwarding scenarios.
[0031] In this embodiment, the controller LAN packet is determined directly by identifying the Router ID to determine whether it is a controller LAN-to-controller LAN forwarding scenario (CAN2CAN), a controller LAN-to-Ethernet forwarding scenario (CAN2ETH), or a controller LAN-to-Ethernet-to-controller LAN forwarding scenario (CAN2ETH2CAN).
[0032] Furthermore, the encapsulation method corresponding to the Controller Area Network (CAN) to CAN forwarding scenario is as-is encapsulation, and the forwarding path is sent from the local CAN port; the encapsulation method corresponding to the CAN to Ethernet forwarding scenario is Time-Sensitive Network Frame (TSFR) encapsulation, and the forwarding path is sent from the Ethernet port; the encapsulation method corresponding to the CAN to Ethernet to CAN forwarding scenario is Audio / Video Transmission Protocol (AVTP) tunnel encapsulation, and the forwarding path is transmitted via the Ethernet backbone to the peer switching chip for decapsulation before being sent.
[0033] In this embodiment, CAN2CAN, CAN2ETH, and CAN2ETH2CAN are three target forwarding scenarios defined by this solution to address different forwarding requirements. They correspond to three different protocol parsing methods, encapsulation methods, and hardware forwarding paths, all relying on the same switching chip for identification and encapsulation. In the CAN2CAN scenario, a packet enters from one CAN port, its ID is parsed, a table is looked up inside the switching chip, and it is directly sent to another CAN port with zero-copy DMA, without touching Ethernet throughout the process, resulting in minimal latency, controllable within tens of nanoseconds. The CAN2ETH scenario can be viewed as a "one-way backbone": the packet is immediately encapsulated into an AVTP frame by the hardware protocol stack, with a timestamp, VLAN, or TSN gating added, and then sent out from the MAC port without returning to CAN. This path is used to send sensor or actuator data to the central domain controller at high speed, or for diagnostic instruments to monitor, achieving delivery within hundreds of microseconds. The CAN2ETH2CAN scenario can be viewed as a "cross-gateway tunnel": the source switching chip adds an AVTP header to the CAN frame, marks its priority, and transmits it to the peer switching chip via the Ethernet backbone. The peer switching chip then decapsulates the frame in hardware, restores the original ID and priority, and finally sends it to the target CAN port via DMA. Since both hops are hardware-pipelined, the end-to-end bandwidth remains gigabit, and the two-hop time is within 10µs, meeting the real-time requirements of multi-segment collaboration in industrial production lines or vehicle bodies. All three target forwarding scenarios are uniformly driven by a hardware decision engine of "identifying Router ID - checking TCAM - scenario-based encapsulation," without CPU intervention. Therefore, the latency of traditional software gateways (5-10 milliseconds) can be reduced to the level of hundreds of microseconds or even single-digit microseconds, while freeing up processor computing power.
[0034] Furthermore, when the target forwarding scenario is a Controller Area Network (CAN) to CAN forwarding scenario, the step of performing protocol parsing on the CAN packet based on the hardware logic built into the switching chip according to the target forwarding scenario, encapsulating it according to the encapsulation method corresponding to the target forwarding scenario, and sending it along the forwarding path corresponding to the target forwarding scenario includes: Step b1: The hardware parsing layer of the switching chip performs protocol parsing on the controller LAN message to obtain the parsed message.
[0035] Here, after the CAN controller completes the physical layer reception, the hardware parsing layer extracts the 11 / 29-bit identifier and the first four bytes of the data field in parallel within the same clock cycle to form the parsed message; at the same time, it saves the original priority information, skips the software protocol stack processing, and provides a basis for subsequent priority mapping.
[0036] Step b2: The direct memory access engine of the switching chip moves the parsed message from the input FIFO buffer of the switching chip to the output FIFO buffer of the switching chip.
[0037] Please see here. Figure 2 , Figure 2 This is a schematic diagram of a controller area network (MAN) to MAN forwarding scenario in an embodiment of this application. For example... Figure 2 As shown, the hardware parsing layer writes the parsed message into the input first-in-first-out (FIFO) buffer; the TCAM routing table completes the matching within the same clock domain through ID mask (e.g., ID[28:24] defines the domain identifier) to quickly determine the target CAN port (e.g., Port1 corresponds to the ID range 0x100-0x1FF); after successful matching, the DMA engine uses zero-copy technology to directly move the data frame from the input FIFO to the transmit FIFO of the target CAN controller, avoiding memory copying and CPU intervention.
[0038] Step b3: The parsed message is sent to the corresponding controller LAN by the controller LAN port of the switching chip.
[0039] Here, after sending the last bit of the FIFO push frame, the hardware automatically maps the original priority saved in step b1 to the target CAN channel (CAN ID priority → VLAN priority inheritance) and immediately sends it through the target CAN port; the entire process of parsing → table lookup → forwarding is completed by the hardware pipeline, and the measured end-to-end delay is less than 5 microseconds, which is suitable for real-time control scenarios of multiple CAN domains.
[0040] Furthermore, when the target forwarding scenario is a Controller Area Network (CAN) to Ethernet forwarding scenario, the step of parsing the CAN packet according to the protocol based on the hardware logic built into the switching chip, encapsulating it according to the encapsulation method corresponding to the target forwarding scenario, and then sending it along the forwarding path corresponding to the target forwarding scenario includes: Step c1: The hardware parsing layer of the switching chip performs protocol parsing on the controller LAN message to obtain the parsed message.
[0041] Here, after the CAN controller completes the physical layer reception, the hardware parsing layer extracts the 11 / 29-bit identifier and all valid bytes of the data field in parallel within the same clock cycle to form the parsed message and saves the original timestamp information to provide a time synchronization reference for subsequent Ethernet encapsulation.
[0042] Step c2: The time-sensitive network frame encapsulation engine of the switching chip encapsulates the parsed message into a time-sensitive network frame and sets the quality of service priority flag of the parsed message.
[0043] Here, the Time-Sensitive Networking (TSN) frame encapsulation engine directly maps the parsed message data field to the EthernetPayload, maintaining the synchronization of the timestamp saved in step c1; at the same time, it parses the CAN identifier into the EtherNet / IP CIP header, completing the protocol conversion; then, it enables the TSN mechanism, sets the quality of service priority flag, and ensures that the frame obtains a deterministic transmission time slot in the Ethernet link.
[0044] Step c3: The Ethernet Media Access Control sublayer of the switching chip sends the time-sensitive network frame to the Ethernet port of the switching chip.
[0045] Please see here. Figure 3 , Figure 3 This is a schematic diagram of a controller area network (MAN) - Ethernet forwarding scenario in an embodiment of this application. Figure 3 As shown, the Ethernet Media Access Control (MAC) sublayer pushes the encapsulated Time-Sensitive Network Frames to the Ethernet port according to the TSN gating list, completing the low-latency, deterministic forwarding from CAN to Ethernet. The entire process is implemented by hardware logic, without the participation of the central processing unit.
[0046] Furthermore, when the target forwarding scenario is a Controller Area Network (CAN) - Ethernet - CAN forwarding scenario, the step of parsing the CAN packet according to the protocol based on the hardware logic built into the switching chip, encapsulating it according to the encapsulation method corresponding to the target forwarding scenario, and sending it along the forwarding path corresponding to the target forwarding scenario includes: Step d1: The hardware parsing layer of the switching chip performs protocol parsing on the controller LAN message to obtain the parsed message.
[0047] Here, the hardware parsing layer of the switching chip directly performs protocol parsing operations on the received Controller Area Network (CAN) packets, identifying and extracting key information such as identifiers and data payloads for subsequent encapsulation and forwarding. This process is entirely automated by the hardware logic, without the intervention of the central processing unit, thus ensuring high efficiency and low latency in data transmission.
[0048] Step d2: The audio and video transmission protocol tunnel encapsulation module of the switching chip performs tunnel encapsulation on the parsed message according to the audio and video transmission protocol, and adds a virtual LAN tag and priority mark to the parsed message to obtain the tunnel encapsulation frame of the controller LAN message.
[0049] Please see here. Figure 4 , Figure 4 This is a schematic diagram of a controller area network (MAN) - Ethernet - MAN forwarding scenario in an embodiment of this application. For example... Figure 4 As shown, after the source switching chip parses the CAN frame ID, it checks the routing table and finds that the target node belongs to a remote CAN domain (e.g., ID[28:24]=0x5 corresponds to a domain managed by another gateway), triggering cross-gateway forwarding logic. The CAN frame is encapsulated into an Ethernet data packet by the hardware protocol engine, using the AVTP protocol to retain the original CAN ID and timestamp, and adding a VLAN tag (802.1Q) and marking the DSCP priority to obtain the tunnel encapsulation frame of the controller LAN message.
[0050] Step d3: The Ethernet Media Access Control (MAC) sublayer of the switching chip sends the tunnel encapsulation frame to the Ethernet port, which is then transmitted to the peer switching chip via the Ethernet backbone. This allows the hardware decapsulation module of the peer switching chip to decapsulate the tunnel encapsulation frame, obtaining the Controller Area Network (CAN) message. The CAN port of the peer switching chip then sends the CAN message to the corresponding CAN network.
[0051] Here, the encapsulated message is sent to the destination switching chip via the MAC layer of the switching chip, and transmitted through the T1 link, during which QoS scheduling is supported to ensure deterministic latency. The destination switching chip identifies the AVTP identifier through the TCAM table, extracts the original CAN frame after stripping the Ethernet header, synchronously verifies the ID validity and maps the priority. The decapsulated CAN frame is sent to the corresponding CAN controller via DMA pass-through, without CPU intervention throughout the process, with an end-to-end latency of <10μs. In this way, through hardware-level protocol conversion and tunneling mechanisms, transparent communication between CAN nodes across domains is achieved, supporting the collaborative control needs of multiple network segments, such as in automotive production lines.
[0052] This application provides a data transmission method applied to a switching chip, comprising: acquiring a Controller Area Network (CAN) packet and extracting its characteristic fields; determining the target forwarding scenario of the CAN packet, as well as the encapsulation method and forwarding path corresponding to the target forwarding scenario, based on the characteristic fields of the CAN packet and a hardware routing table; performing protocol parsing on the CAN packet based on the hardware logic built into the switching chip, encapsulating it according to the encapsulation method corresponding to the target forwarding scenario, and sending it along the forwarding path corresponding to the target forwarding scenario; wherein the central processing unit (CPU) does not participate in the protocol parsing, encapsulation, and sending process. In this way, through the hardware logic built into the switching chip, the switching chip independently completes protocol parsing, encapsulation, and forwarding without the intervention of the CPU, thereby improving the transmission efficiency of bus data transmission.
[0053] Based on the same application concept, this application also provides a data transmission device corresponding to the data transmission method provided in the above embodiments. Since the principle of the device in this application is similar to the data transmission method in the above embodiments of this application, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be described again.
[0054] Please see Figure 5 , Figure 5 This is a functional block diagram of a data transmission device provided in an embodiment of this application. Figure 5 As shown, the data transmission device 500 provided in this embodiment is applied to a switching chip, and the data transmission device 500 includes: The data acquisition module 510 is used to acquire controller local area network (LAN) packets and extract the characteristic fields of the LAN packets.
[0055] The scenario determination module 520 is used to determine the target forwarding scenario of the controller local area network (Controller Area Network) packet, as well as the encapsulation method and forwarding path corresponding to the target forwarding scenario, based on the feature fields of the Controller Area Network packet and the hardware routing table.
[0056] The protocol conversion module 530 is used to perform protocol parsing on the controller LAN packets based on the hardware logic built into the switching chip for the target forwarding scenario, and then encapsulate them according to the encapsulation method corresponding to the target forwarding scenario before sending them along the forwarding path corresponding to the target forwarding scenario; wherein, the central processing unit does not participate in the protocol parsing, encapsulation and sending process.
[0057] Furthermore, when the scenario determination module 520 determines the target forwarding scenario of the controller LAN packet, as well as the encapsulation method and forwarding path corresponding to the target forwarding scenario, based on the feature fields of the controller LAN packet and the hardware routing table, the scenario determination module 520 is specifically used for: The identifier in the feature field is divided into domains using a bitmask to obtain the domain identifier of the controller LAN packet; The domain identifier is compared in parallel with the entries in the tri-state content addressing memory to obtain the matching entries for the domain identifier; the matching entries include the target forwarding scenario, encapsulation method, and output port information of the controller LAN packet corresponding to the domain identifier; Based on the matching entries of the domain identifier, the target forwarding scenario of the controller LAN packet, as well as the encapsulation method and forwarding path corresponding to the target forwarding scenario, are determined.
[0058] Furthermore, when the target forwarding scenario is a Controller Area Network (CAN) to CAN forwarding scenario, the protocol conversion module 530, based on the hardware logic built into the switching chip according to the target forwarding scenario, performs protocol parsing on the CAN packet, encapsulates it according to the encapsulation method corresponding to the target forwarding scenario, and sends it along the forwarding path corresponding to the target forwarding scenario. Specifically, the protocol conversion module 530 is used to: The hardware parsing layer of the switching chip performs protocol parsing on the controller LAN packets to obtain the parsed packets; The direct memory access engine of the switching chip moves the parsed message from the input first-in-first-out buffer of the switching chip to the output first-in-first-out buffer of the switching chip; The parsed message is sent to the corresponding controller local area network by the controller local area network port of the switching chip.
[0059] Furthermore, when the target forwarding scenario is a Controller Area Network (CAN) to Ethernet forwarding scenario, the protocol conversion module 530, based on the hardware logic built into the switching chip according to the target forwarding scenario, performs protocol parsing on the CAN packet, encapsulates it according to the encapsulation method corresponding to the target forwarding scenario, and sends it along the forwarding path corresponding to the target forwarding scenario. Specifically, the protocol conversion module 530 is used to: The hardware parsing layer of the switching chip performs protocol parsing on the controller LAN packets to obtain the parsed packets; The time-sensitive network frame encapsulation engine of the switching chip encapsulates the parsed packet into a time-sensitive network frame and sets the quality of service priority flag of the parsed packet. The time-sensitive network frame is sent to the Ethernet port of the switching chip by the Ethernet Media Access Control sublayer of the switching chip.
[0060] Furthermore, when the target forwarding scenario is a Controller Area Network (CAN) - Ethernet - CAN forwarding scenario, the protocol conversion module 530, based on the hardware logic built into the switching chip according to the target forwarding scenario, performs protocol parsing on the CAN packet, encapsulates it according to the encapsulation method corresponding to the target forwarding scenario, and sends it along the forwarding path corresponding to the target forwarding scenario. Specifically, the protocol conversion module 530 is used to: The hardware parsing layer of the switching chip performs protocol parsing on the controller LAN packets to obtain the parsed packets; The audio and video transmission protocol tunnel encapsulation module of the switching chip performs tunnel encapsulation on the parsed message according to the audio and video transmission protocol, and adds a virtual LAN tag and priority mark to the parsed message to obtain the tunnel encapsulation frame of the controller LAN message; The Ethernet Media Access Control (MAC) sublayer of the switching chip sends the tunnel encapsulation frame to the Ethernet port, which is then transmitted to the peer switching chip via the Ethernet backbone. The hardware decapsulation module of the peer switching chip decapsulates the tunnel encapsulation frame to obtain the Controller Area Network (CAN) message, which in turn sends the CAN message to the corresponding Controller Area Network (CLAN) via the CAN port of the peer switching chip.
[0061] This application provides a data transmission device comprising: a data acquisition module for acquiring controller local area network (Controller Area Network) packets and extracting feature fields from the Controller Area Network packets; a scenario determination module for determining the target forwarding scenario of the Controller Area Network packets, as well as the encapsulation method and forwarding path corresponding to the target forwarding scenario, based on the feature fields of the Controller Area Network packets and a hardware routing table; and a protocol conversion module for parsing the Controller Area Network packets according to the protocol based on the hardware logic built into the switching chip, encapsulating the packets according to the encapsulation method corresponding to the target forwarding scenario, and sending them along the forwarding path corresponding to the target forwarding scenario. The central processing unit (CPU) does not participate in the protocol parsing, encapsulation, and transmission process. Thus, by using the hardware logic built into the switching chip, the switching chip independently completes protocol parsing, encapsulation, and forwarding without the intervention of the CPU, thereby improving the transmission efficiency of bus data transmission.
[0062] Based on the same application concept, please refer to Figure 6 , Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 6As shown, the electronic device 600 includes a switching chip 610, a controller area network (MAN) bus 620, a MAN node 630, and an Ethernet link 640. The switching chip 610 has built-in hardware logic for the data transmission method provided in the above embodiments. At least one MAN port of the switching chip 610 is connected to the MAN bus 620. At least one MAN node 630 is connected to the MAN bus 620. At least one Ethernet port of the switching chip 610 is connected to the Ethernet ports of other switching chips 610 via the Ethernet link 640.
[0063] Based on the same concept, this application also provides a computer-readable storage medium storing a computer program, which executes the steps of the data transmission method provided in the above embodiments when loaded by the hardware logic built into the switching chip.
[0064] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Additionally, the displayed or discussed mutual couplings, direct couplings, or communication connections may be through some communication interfaces; indirect couplings or communication connections between devices or units may be electrical, mechanical, or other forms.
[0065] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0066] In addition, the functional units in the embodiments provided in this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0067] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0068] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. In addition, the terms "first", "second", "third", etc. are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0069] Finally, it should be noted that the above-described embodiments are merely specific implementations of this application, used to illustrate the technical solutions of this application, and not to limit them. The protection scope of this application is not limited thereto. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features, within the scope of the technology disclosed in this application; and these modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application. All should be covered within the protection scope of this application. Therefore, the protection scope of this application should be determined by the protection scope of the claims.
Claims
1. A data transmission method, characterized in that, Applied to a switching chip, the method includes: Acquire controller local area network (Controller Area Network) packets and extract the characteristic fields of the controller local area network (Controller Area Network) packets; Based on the characteristic fields of the controller area network (CLAN) packets and the hardware routing table, the target forwarding scenario of the CLAN packets, as well as the encapsulation method and forwarding path corresponding to the target forwarding scenario, are determined. Based on the hardware logic built into the switching chip for the target forwarding scenario, the controller LAN packet is parsed according to the protocol, encapsulated according to the encapsulation method corresponding to the target forwarding scenario, and then sent along the forwarding path corresponding to the target forwarding scenario; wherein, the central processing unit does not participate in the protocol parsing, encapsulation and sending process.
2. The data transmission method according to claim 1, characterized in that, The step of determining the target forwarding scenario of the Controller Area Network (CAN) packet, as well as the encapsulation method and forwarding path corresponding to the target forwarding scenario, based on the characteristic fields of the CAN packet and the hardware routing table, includes: The identifier in the feature field is divided into domains using a bitmask to obtain the domain identifier of the controller LAN packet; The domain identifier is compared in parallel with the entries in the tri-state content addressing memory to obtain the matching entries for the domain identifier; the matching entries include the target forwarding scenario, encapsulation method, and output port information of the controller LAN packet corresponding to the domain identifier; Based on the matching entries of the domain identifier, the target forwarding scenario of the controller LAN packet, as well as the encapsulation method and forwarding path corresponding to the target forwarding scenario, are determined.
3. The data transmission method according to claim 2, characterized in that, The target forwarding scenarios include Controller Area Network (CAN) to CAN forwarding scenarios, CAN to Ethernet forwarding scenarios, and CAN to Ethernet to CAN forwarding scenarios.
4. The data transmission method according to claim 3, characterized in that, The encapsulation method for the Controller Area Network (CAN) to CAN forwarding scenario is "as is" encapsulation, and the forwarding path is sent from the local CAN port; the encapsulation method for the CAN to Ethernet forwarding scenario is Time-Sensitive Network Frame (TSFR) encapsulation, and the forwarding path is sent from the Ethernet port; the encapsulation method for the CAN to Ethernet to CAN forwarding scenario is Audio / Video Transmission Protocol (AVTP) tunnel encapsulation, and the forwarding path is transmitted via the Ethernet backbone to the peer switching chip for decapsulation before being sent.
5. The data transmission method according to claim 4, characterized in that, When the target forwarding scenario is a Controller Area Network (CAN) to CAN forwarding scenario, the step of parsing the CAN packet according to the protocol based on the hardware logic built into the switching chip, encapsulating it according to the encapsulation method corresponding to the target forwarding scenario, and sending it along the forwarding path corresponding to the target forwarding scenario includes: The hardware parsing layer of the switching chip performs protocol parsing on the controller LAN packets to obtain the parsed packets; The direct memory access engine of the switching chip moves the parsed message from the input first-in-first-out buffer of the switching chip to the output first-in-first-out buffer of the switching chip; The parsed message is sent to the corresponding controller local area network by the controller local area network port of the switching chip.
6. The data transmission method according to claim 4, characterized in that, When the target forwarding scenario is a Controller Area Network (CAN) to Ethernet forwarding scenario, the step of parsing the CAN packet according to the protocol based on the hardware logic built into the switching chip, encapsulating it according to the encapsulation method corresponding to the target forwarding scenario, and sending it along the forwarding path corresponding to the target forwarding scenario includes: The hardware parsing layer of the switching chip performs protocol parsing on the controller LAN packets to obtain the parsed packets; The time-sensitive network frame encapsulation engine of the switching chip encapsulates the parsed packet into a time-sensitive network frame and sets the quality of service priority flag of the parsed packet. The time-sensitive network frame is sent to the Ethernet port of the switching chip by the Ethernet Media Access Control sublayer of the switching chip.
7. The data transmission method according to claim 4, characterized in that, When the target forwarding scenario is a Controller Area Network (CAN) - Ethernet - CAN forwarding scenario, the step of parsing the CAN packet according to the protocol based on the hardware logic built into the switching chip, encapsulating it according to the encapsulation method corresponding to the target forwarding scenario, and sending it along the forwarding path corresponding to the target forwarding scenario includes: The hardware parsing layer of the switching chip performs protocol parsing on the controller LAN packets to obtain the parsed packets; The audio and video transmission protocol tunnel encapsulation module of the switching chip performs tunnel encapsulation on the parsed message according to the audio and video transmission protocol, and adds a virtual LAN tag and priority mark to the parsed message to obtain the tunnel encapsulation frame of the controller LAN message; The Ethernet Media Access Control (MAC) sublayer of the switching chip sends the tunnel encapsulation frame to the Ethernet port, which is then transmitted to the peer switching chip via the Ethernet backbone. The hardware decapsulation module of the peer switching chip decapsulates the tunnel encapsulation frame to obtain the Controller Area Network (CAN) message, which in turn sends the CAN message to the corresponding Controller Area Network (CLAN) via the CAN port of the peer switching chip.
8. A data transmission device, characterized in that, The data transmission device, applied to a switching chip, includes: The data acquisition module is used to acquire controller local area network (Controller Area Network) packets and extract the characteristic fields of the Controller Area Network (Controller Area Network) packets. The scenario determination module is used to determine the target forwarding scenario of the controller local area network (Controller Area Network) packet, as well as the encapsulation method and forwarding path corresponding to the target forwarding scenario, based on the feature fields of the Controller Area Network (Controller Area Network) packet and the hardware routing table. The protocol conversion module is used to parse the controller LAN packets based on the hardware logic built into the switching chip according to the target forwarding scenario, encapsulate them according to the encapsulation method corresponding to the target forwarding scenario, and send them along the forwarding path corresponding to the target forwarding scenario; wherein, the central processing unit does not participate in the protocol parsing, encapsulation and sending process.
9. An electronic device, characterized in that, The device includes a switching chip, a controller area network (MAN) bus, MAN nodes, and an Ethernet link; the switching chip has built-in hardware logic for performing the data transmission method as described in any one of claims 1 to 7; at least one MAN port of the switching chip is connected to the MAN bus; at least one MAN node is connected to the MAN bus; and at least one Ethernet port of the switching chip is connected to the Ethernet port of other switching chips via an Ethernet link.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when loaded by the hardware logic built into the switching chip, executes the steps of the data transmission method as described in any one of claims 1 to 7.