Method for fast forwarding of CAN messages, CAN acceleration device, electronic device, readable storage medium and computer program product

CN122970055APending Publication Date: 2026-10-23SANECHIPS TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510508519.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-22
Publication Date
2026-10-23

AI Technical Summary

Technical Problem

随着CAN控制应用越来越多,对其带宽要求变高,需要协议栈处理的CAN转发报文就越多,大量的CAN报文路由全部由CPU软协议栈维护和处理,无疑对CPU处理性能要求越来越高,当CPU处理大量的CAN报文时,CPU性能同步会下降,转发延时变长

Benefits of technology

[0010]本申请实施例提供的一种CAN报文快速转发方法、CAN加速设备、电子设备、可读存储介质和计算机程序产品,CAN加速设备设置在主处理器CPU与CAN收发器之间,实现主处理器的CAN流量卸载。将需要进行CAN报文接收、发送等需要高性能和高消耗的功能由硬件转发模块完成,而需要对报文进行的switch处理由软件可编程模块实现,不仅提高了CAN转发性能,还灵活实现了各种不同场景下对CAN流量卸载以及swtich功能的支持,能够有效的降低can转发延时,大大提高CAN通信性能。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122970055A_ABST
    Figure CN122970055A_ABST
Patent Text Reader

Abstract

The application discloses a CAN message fast forwarding method, a CAN acceleration device, an electronic device, a readable storage medium and a computer program product, and belongs to the technical field of communication. The method comprises the following steps: an acceleration device acquires a first CAN message, and stores the first CAN message into a RAM according to a preset rule, wherein the acceleration device is arranged between a main processor and a CAN transceiver; the acceleration device performs switch exchange processing on the first CAN message to obtain a second CAN message, updates the first CAN message in the RAM into the second CAN message, and acquires message description information of the second CAN message; and the acceleration device takes out the second CAN message from the RAM according to the message description information, and sends the second CAN message to the CAN transceiver.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of communication technology, and in particular to a method for fast forwarding of CAN messages, a CAN acceleration device, an electronic device, a readable storage medium, and a computer program product. Background Technology

[0002] Controller Area Network (CAN) bus is widely used in industrial fields and is an indispensable communication protocol in automotive, aerospace, and aviation industries. With the rise of various new technologies in the automotive sector, the requirements for the stability and processing latency of the CAN bus are becoming increasingly stringent.

[0003] Traditional microcontroller units (MCUs) or microprocessor units (MPUs) primarily implement CAN message routing and forwarding through the software protocol stack within their internal main processor (CPU). Interaction between different CAN controllers requires the participation of the CAN protocol stack. As CAN control applications become more prevalent and bandwidth requirements increase, the number of CAN message forwarding messages that the protocol stack needs to process also increases. The fact that the CPU's software protocol stack maintains and processes the routing of a large number of CAN messages undoubtedly places increasingly higher demands on CPU processing performance. When the CPU processes a large number of CAN messages, its performance will simultaneously decrease, and forwarding latency will increase. Summary of the Invention

[0004] This application provides a method for fast forwarding of CAN messages, a CAN acceleration device, an electronic device, a readable storage medium, and a computer program product. It can solve the problem in the related technology that the traditional MCU implements the routing and forwarding of CAN messages through the software protocol stack in its internal main processor CPU. When the CPU processes a large number of CAN messages, the CPU performance decreases synchronously and the forwarding delay becomes longer.

[0005] To solve the above-mentioned technical problems, this application is implemented as follows: Firstly, a method for fast forwarding of CAN messages is provided, including: The acceleration device acquires the first CAN message and stores the first CAN message in RAM according to a preset rule. The acceleration device is located between the main processor and the CAN transceiver. The acceleration device performs a switch operation on the first CAN message to obtain a second CAN message, updates the first CAN message in the RAM to the second CAN message, and obtains the message description information of the second CAN message. The acceleration device retrieves the second CAN message from the RAM according to the message description information and sends the second CAN message to the CAN transceiver.

[0006] Secondly, a CAN acceleration device is provided, which is disposed between a main processor and a CAN transceiver. The CAN acceleration device includes: a CAN controller, a hardware forwarding module, a software programmable module, and RAM, wherein: The hardware forwarding module is used to acquire the first CAN message and store the first CAN message in RAM according to a preset rule; The software programmable module is used to perform switch exchange processing on the first CAN message to obtain the second CAN message, update the first CAN message in the RAM to the second CAN message, and obtain the message description information of the second CAN message; The hardware forwarding module is further configured to retrieve the second CAN message from the RAM according to the message description information, and send the second CAN message to the CAN transceiver through the CAN controller; The CAN controller is used to send the second CAN message to the CAN transceiver.

[0007] Thirdly, an electronic device is provided, comprising a processor and a memory, the memory storing at least one computer program, the at least one computer program being loaded and executed by the processor to implement the above-described CAN message fast forwarding method.

[0008] Fourthly, a readable storage medium is provided, wherein at least one computer program is stored in the readable storage medium, the computer program being loaded and executed by a processor to implement the above-described CAN message fast forwarding method.

[0009] Fifthly, a computer program product is provided, the computer program product comprising at least one computer program, the computer program being loaded and executed by a processor to implement the CAN message fast forwarding method provided in the various optional implementations described above.

[0010] This application provides a CAN message fast forwarding method, a CAN acceleration device, an electronic device, a readable storage medium, and a computer program product. The CAN acceleration device is positioned between the main processor CPU and the CAN transceiver to offload CAN traffic from the main processor. High-performance and high-consumption functions such as CAN message reception and transmission are performed by a hardware forwarding module, while the switch processing of messages is implemented by a software programmable module. This not only improves CAN forwarding performance but also flexibly supports CAN traffic offloading and switch functions in various scenarios, effectively reducing CAN forwarding latency and significantly improving CAN communication performance.

[0011] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this application. Attached Figure Description

[0012] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0013] Figure 1 A flowchart of a fast CAN message forwarding method provided in an exemplary embodiment of this application is shown; Figure 2 This application shows a structural block diagram of a CAN acceleration device provided in an exemplary embodiment. Figure 3 This paper shows a schematic diagram of the routing lookup module provided in an application example of this application; Figure 4 A structural block diagram of an electronic device provided in an exemplary embodiment of this application is shown. Detailed Implementation

[0014] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.

[0015] To address the problem in existing technologies where MCUs traditionally route and forward CAN messages through the software protocol stack in their internal main processor CPU, resulting in decreased CPU performance and increased forwarding delays when processing a large number of CAN messages, this application provides a method for fast CAN message forwarding.

[0016] The execution entity of this method can be various types of computing devices, or it can be a CAN acceleration system integrated into a computing device. The computing device can be an acceleration device, such as an MCU or MPU with an integrated CAN acceleration system.

[0017] For ease of description, this application uses an acceleration device as an example to illustrate the method. Those skilled in the art will understand that this embodiment uses the acceleration device as an example to describe the method, which is merely an illustrative example and does not limit the scope of protection of the corresponding claims.

[0018] Figure 1 A flowchart illustrating a fast CAN message forwarding method according to an exemplary embodiment of this application is shown. Figure 1 As shown, this CAN message fast forwarding method mainly includes the following steps (S101-S103): S101, the acceleration device acquires the first CAN message and stores the first CAN message into RAM according to preset rules.

[0019] In this embodiment, the acceleration device is positioned between the main processor CPU and the CAN transceiver. In some embodiments, the first CAN message is obtained from either the main processor CPU or the CAN transceiver. The acceleration device is connected to the main processor CPU via a Network on Chip (NOC) or other bus. The main processor CPU interacts with the acceleration device through interrupt services, control access, etc., to transmit CAN messages and control the operation of the acceleration device. Simultaneously, the acceleration device interfaces with the CAN transceiver through its CAN controller, receiving CAN messages from the CAN bus and sending CAN messages back to the CAN bus via the CAN transceiver.

[0020] In some embodiments, the CAN controller in the acceleration device includes multiple channels. By polling or interrupt handling, each CAN controller channel is checked to obtain the first CAN message cached in each channel and moved to the random access memory (RAM) for storage according to preset rules. In some embodiments, these preset rules may include, but are not limited to, organizing the storage according to message priority, reception time order, or other specific logic such as a unified index or linked list, so that these CAN messages can be accessed quickly and accurately subsequently.

[0021] In some embodiments, the first CAN message includes multiple channels. In this embodiment, the acceleration device has the ability to simultaneously receive multiple first CAN messages from the CAN controller and the main processor CPU, and can process these message inputs from different sources in parallel. In some embodiments, after the acceleration device acquires the first CAN message, before storing the first CAN message in RAM according to a preset rule, the method provided in this embodiment further includes: the acceleration device performing priority scheduling processing between or within CAN controller channels on the multiple first CAN messages, and performing concurrent processing on the multiple first CAN messages from different directions.

[0022] In this embodiment, the acceleration device performs priority scheduling processing on multiple first CAN messages between or within CAN controller channels. In practice, different CAN controller channels (PORTs) may simultaneously have first CAN messages requiring processing, and each channel may also contain multiple first CAN messages. The acceleration device performs priority scheduling on these messages, considering both the priority order between different channels (between PORTs) and the priority order within the same channel (within a PORT). For example, urgent control messages may be assigned higher priority and processed first. The acceleration device ensures that more urgent CAN messages are processed and transmitted first, thereby improving communication efficiency and quality.

[0023] In this embodiment, the acceleration device performs concurrent processing on multiple first CAN messages from different directions. In practice, the first CAN messages contain messages from different directions, such as those for sending, receiving, and events. The acceleration device can simultaneously process these messages from different directions, improving system processing efficiency and ensuring that all types of messages receive timely responses.

[0024] In this embodiment, before the acceleration device acquires the first CAN message, the main processor needs to initialize the acceleration device. The initialization of the acceleration device by the main processor includes, but is not limited to, routing rule configuration, CAN controller initialization, software code loading, interrupt handling logic initialization, etc. After initialization is completed, the entire acceleration device system enters the preparation stage of waiting for CAN message reception.

[0025] S102, the acceleration device performs switch exchange processing on the first CAN message to obtain the second CAN message, updates the first CAN message in RAM to the second CAN message, and obtains the message description information of the second CAN message; In some embodiments, before the acceleration device performs switch processing on the first CAN message, the method provided in this embodiment further includes: the acceleration device extracts key information from the first CAN message to construct a key value, initiates a route lookup request, and obtains the routing rule information of the first CAN message, wherein the information carried in the route lookup request includes the key value; the acceleration device performs switch processing on the first CAN message, including: the acceleration device performs switch processing on the first CAN message according to the routing rule information.

[0026] In this embodiment, the acceleration device extracts key information from the first CAN message, including the CAN controller's channel number and the message's common attributes (such as specific fields of the message itself). Then, it constructs a key using this key information. In this embodiment, the key extraction rules are not limited and can be flexibly configured according to the actual application. The key is then extracted from the first CAN message according to the configured rules and assembled into the final key. This key will serve as the basis for looking up the routing table, determining how the first CAN message should be processed and forwarded subsequently.

[0027] In some embodiments, the information carried in the routing lookup request further includes: the buffer ID of the first CAN message stored in RAM; and the acceleration device performing switch processing on the first CAN message, including: the acceleration device performing switch processing on the first CAN message based on the buffer ID. In this embodiment, the initiated routing lookup request carries not only a key value but also the buffer ID of the first CAN message stored in RAM. This additional information will be passed to the software programmable module of the acceleration device, which can accurately read the corresponding first CAN message from RAM using the buffer ID and perform further switch processing on the first CAN message based on the routing lookup result.

[0028] In some embodiments, after the acceleration device initiates a route lookup request and before obtaining the routing rule information of the first CAN message, the method provided in this embodiment further includes: the acceleration device performing a route lookup based on a mechanism that uses multiple search engines to search in parallel and configures the entry threshold for each search engine; when multiple entries are matched, the first matched entry is selected as the routing rule information for the first CAN message. This ensures that even with multiple matching results, the system can quickly determine a clear routing rule.

[0029] In some embodiments, the acceleration device includes a route lookup module. By initiating a route lookup request to the route lookup module, the device performs a fast route lookup and returns the routing rule information of the first CAN message. The route lookup module is configured with multiple search engine units (Search Engines) for parallel searches. When allocating entries, each search engine is configured with a number of valid entries less than or equal to an entry threshold. For example, if the route lookup module is configured with 12 search engine units, and the user configures 125 entries, the first 5 search engine units each write 11 entries with a threshold of 11; the last 7 search engine units each write 10 entries with a threshold of 10. The valid entry threshold can significantly reduce the search polling scan time. Each search engine unit polls according to the number of valid entries, searching only within the configured threshold range, avoiding scanning invalid entries, thereby reducing search latency and improving search efficiency. In one application example, Figure 3 This illustration shows a schematic diagram of the routing lookup module according to an exemplary embodiment of this application. For details, please refer to the following CAN acceleration device embodiment. Figure 3 The description is as follows. Therefore, by using the above routing lookup scheme, the routing rule information of the first CAN message can be quickly found.

[0030] In this embodiment, after obtaining the routing rule information of the first CAN message, the acceleration device can perform switch processing on the first CAN message to obtain the second CAN message. In some embodiments, the switch processing includes at least one of the following: route resolution, message format conversion, message modification, message encapsulation, unicast or multicast processing, and message distribution management.

[0031] Specifically, the acceleration device can parse the routing rules as needed based on the routing rule information of the acquired first CAN message, and perform protocol conversion between CAN and Controller Area Network Flexible Data-Rate (CAN FD) messages for the message format of the first CAN message. Since CAN and CAN FD differ in data transmission rate, data length, etc., protocol conversion between CAN and CAN FD messages is performed on the message format of the first CAN message to meet the communication needs between different devices or systems.

[0032] In addition, in some embodiments, the acceleration device can also modify the first CAN message, for example, by modifying certain data fields or identifiers in the message to meet specific business requirements or communication protocol requirements.

[0033] In other embodiments, the acceleration device can also perform encapsulation operations such as adding or modifying header information and checksum information on the first CAN message. For example, depending on different protocol conversion requirements, specific header fields of the CAN FD message can be added or modified, or the checksum field of the message can be updated to ensure the correctness and integrity of the message during transmission.

[0034] In other embodiments, the acceleration device can also be configured to transmit the first CAN message as either unicast or multicast.

[0035] In other embodiments, the acceleration device can also perform message distribution management on the first CAN message based on routing rules and system-defined priorities. For example, it can determine the message processing order, arrange which messages are sent first and which are sent later, and perform operations such as message storage and retrieval to enable quick location and processing of messages when needed.

[0036] In this embodiment, the message description information of the second CAN message mainly includes: key attributes of the second CAN message, such as the target address of the message, the channel information to which the message belongs, the buffer ID stored in RAM, the message direction, the message priority, etc. The acceleration device will decide how to process and send the second CAN message based on these message description information.

[0037] S103, the acceleration device retrieves the second CAN message from the RAM according to the message description information and sends the second CAN message to the CAN transceiver.

[0038] In some embodiments, the acceleration device retrieves a second CAN message from RAM based on message description information and sends the second CAN message to the CAN transceiver. This includes: the acceleration device determining the message scheduling priority and transmission processing method based on the message description information of the second CAN message; retrieving the second CAN message from RAM according to the message scheduling priority and transmission processing method; and sending the second CAN message to the CAN transceiver via the CAN controller. The CAN controller physically connects and communicates with the CAN bus through the CAN transceiver, sending the second CAN message onto the CAN bus via the CAN transceiver, thereby realizing the transmission of the second CAN message throughout the CAN network.

[0039] In some embodiments, the scheduling priority and transmission processing method of messages include at least one of the following: (1) Send messages using unicast or multicast methods; (2) Perform priority scheduling processing between or within CAN controller channels; (3) Perform concurrent processing on messages from different directions.

[0040] For the above method (1), the acceleration device obtains the target address of the message from the message description information and determines the message transmission processing method as unicast or multicast copy based on this information. When the message description information contains only one target address, it indicates that the message needs to be sent unicast. When the message description information contains multiple target addresses, it indicates that the message needs to be sent multicast. The second CAN message needs to be copied, and then the copied message is sent to the CAN controller. The CAN controller then sends the second CAN message to the CAN bus.

[0041] In method (2) above, the acceleration device obtains the channel information to which the message belongs and its priority between or within CAN controller channels from the message description information, and determines the scheduling priority of the message based on this information. It then performs priority scheduling on multiple second CAN messages, considering both the priority order of messages between different CAN controller channels (between ports) and the priority order of messages within the same CAN controller channel (within a port). For example, some urgent control command messages will be assigned a higher priority and sent first.

[0042] In the above method (3), the acceleration device obtains the message direction from the message description information. The second CAN message contains messages in different directions, such as messages in the sending direction, receiving direction, and event direction. The acceleration device can determine the parallel transmission processing method of the message based on this information, and simultaneously process these second CAN messages in different directions concurrently to ensure that the system can efficiently process various types of messages and improve the overall communication efficiency.

[0043] In this embodiment, after determining the scheduling priority and transmission processing method of the message, the acceleration device can accurately retrieve the corresponding second CAN message from RAM based on relevant information in the message description information (such as the buffer ID of the second CAN message stored in RAM), and write it into the corresponding CAN controller channel according to the message scheduling priority and transmission processing method. For example, if the message description information indicates that a certain message is a high-priority unicast message to be sent to a specific CAN controller (specific channel number), this second CAN message can be marked as high priority and its unicast processing method can be determined. Then, the message content can be retrieved according to the buffer ID stored in RAM and written into the CAN controller channel corresponding to the specific channel number, and sent to the CAN bus through the CAN transceiver. As another example, if there are multiple second CAN messages from different channels (PORTs), after determining their priority and message direction through the message description information, the acceleration device can prioritize the high-priority messages, plan which messages can be processed concurrently and which need to be processed sequentially, and then retrieve the corresponding second CAN messages from RAM in sequence and write them into the CAN controller. Therefore, the retrieved second CAN message can be written into each CAN controller for transmission more efficiently according to the message scheduling priority and transmission processing method, reducing processing time and resource waste, and making the entire transmission process more orderly and efficient.

[0044] In some embodiments, the method provided in this embodiment further includes: accelerating the device to obtain abnormal messages, performing aggregation processing on the abnormal messages through software coding, and sending the aggregated abnormal messages to the main processor via an interrupt.

[0045] In this embodiment, the CAN controller may detect various abnormal situations during operation, such as bus errors and message errors; the acceleration device may also encounter hardware failures or other abnormal events. After obtaining abnormal messages, the acceleration device performs aggregation processing on these messages through software coding. In some embodiments, aggregation processing includes, but is not limited to, merging and analyzing multiple similar or related abnormal messages and extracting key information. After aggregation processing, the acceleration device sends the aggregated abnormal messages to the main processor for processing via an interrupt (int) according to certain rules. An interrupt is a hardware mechanism used to notify the main processor that there are urgent or important events that need to be handled. Reporting abnormal messages via interrupts ensures that the main processor can respond to and handle these abnormal situations in a timely manner, guaranteeing the stability and reliability of the system.

[0046] An exemplary embodiment of this application provides a CAN acceleration device 10. Figure 2This illustration shows a structural block diagram of a CAN acceleration device 10 provided in an exemplary embodiment of this application. The CAN acceleration device 10 is a device such as an MCU or MPU that integrates a CAN acceleration system. By positioning the main processor CPU and the CAN transceiver between them, it can achieve, for example... Figure 1 The embodiments shown include all or part of the content to achieve CAN traffic offloading. The following is only a brief description of the structure and function of the CAN acceleration device 10; for other matters not covered herein, please refer to the relevant descriptions in the above-described CAN message fast forwarding method. The embodiments of the CAN acceleration device 10 correspond to the embodiments of the above-described CAN message fast forwarding method. All implementation processes and methods of the above-described method embodiments can be applied to the embodiments of the CAN acceleration device and achieve the same technical effects.

[0047] like Figure 2 As shown, the CAN acceleration device 10 includes: a CAN controller 100, a hardware forwarding module 200, a software programmable module 300, and a RAM 400.

[0048] In this embodiment, the hardware forwarding module 200 is used to acquire the first CAN message and store it in the RAM 400 according to a preset rule; the software programmable module 300 is used to perform a switch operation on the first CAN message to obtain the second CAN message, update the first CAN message in the RAM 400 to the second CAN message, and acquire the message description information of the second CAN message; the hardware forwarding module 200 is also used to retrieve the second CAN message from the RAM 400 according to the message description information and send the second CAN message to the CAN transceiver through the CAN controller; the CAN controller 100 is used to send the second CAN message to the CAN transceiver. The RAM 400 is used to store the first CAN message, the second CAN message, and shared communication messages for access by various modules inside the CAN acceleration device 10 and the main processor.

[0049] In this embodiment, the main processor CPU is responsible for initializing the various modules of the CAN acceleration device. Specifically, the user can configure the routing rules for CAN messages according to actual needs, determining how the messages are transmitted and processed in the system. The CAN controller 100 is initialized to enable it to receive and send CAN messages normally; the hardware forwarding module 200 is initialized to prepare for subsequent message processing and forwarding. The software programmable module 300 is initialized by loading the software code into the system and completing the initialization, enabling flexible processing of CAN messages later. The interrupt handling logic is initialized, setting up the interrupt handling mechanism to ensure the system can respond promptly to various anomalies and events. After initialization, the CAN acceleration device enters a state of waiting to receive CAN messages.

[0050] In some embodiments, the first CAN message is obtained from the main processor or CAN transceiver. The hardware forwarding module 200 is connected to the main processor CPU via an on-chip network (NOC) or other bus. The main processor CPU interacts with the hardware forwarding module 200 through interrupt services, control access, etc., to transmit CAN messages and control the operation of the hardware forwarding module 200.

[0051] Meanwhile, the CAN controller 100 interfaces with the CAN transceiver to receive CAN messages from the CAN bus and send CAN messages back to the CAN bus. The hardware forwarding module 200 is connected to the CAN controller 100. The hardware forwarding module 200 checks the buffers of each CAN controller channel through polling or interrupt handling to obtain the first CAN message buffered in each channel of the CAN controller.

[0052] In some embodiments, the hardware forwarding module 200 moves the first CAN messages acquired from each channel of the CAN controller to the random access memory (RAM) for storage according to preset rules. In some embodiments, these preset rules may include, but are not limited to, organizing the storage according to message priority, reception time order, or other specific logic such as unified indexing or linked lists, so that these CAN messages can be accessed quickly and accurately in the future.

[0053] In some embodiments, the first CAN message includes multiple channels. In this embodiment, the hardware forwarding module 200 has the ability to simultaneously receive multiple first CAN messages from the CAN controller and the main processor CPU, and can process these message inputs from different sources in parallel. In some embodiments, the hardware forwarding module 200 is further configured to, after acquiring the first CAN message, perform priority scheduling processing between or within CAN controller channels on the multiple first CAN messages before storing the first CAN message in RAM according to preset rules, and to perform concurrent processing on multiple first CAN messages from different directions.

[0054] In practical implementation, different CAN controller channels (PORTs) may simultaneously have first CAN messages to process, and each channel may also contain multiple first CAN messages. The hardware forwarding module 200 prioritizes these messages, considering both the priority of messages between different channels (between PORTs) and the priority order of messages within the same channel (within a PORT). For example, urgent control messages may be assigned higher priority and processed first. The acceleration device ensures that more urgent CAN messages are processed and transmitted first, thereby improving communication efficiency and quality.

[0055] In practical implementation, the first CAN message contains messages from different directions, such as messages in the sending direction, receiving direction, and event direction. The hardware forwarding module 200 can process these messages from different directions concurrently, improving the system's processing efficiency and ensuring that all types of messages can be responded to in a timely manner.

[0056] In some embodiments, such as Figure 2 As shown, the CAN acceleration device provided in this embodiment also includes a routing query module 500. In this embodiment, the hardware forwarding module 200 is further configured to extract key information from the first CAN message after obtaining the first CAN message, construct a key value, and initiate a routing lookup request, wherein the information carried in the routing lookup request includes the key value; the routing query module 500 is configured to receive the routing lookup request, perform routing lookup based on the key value through a mechanism of parallel searching by multiple search engines and configuring the entry threshold of each search engine, and select the first matched entry to return the routing rule information of the first CAN message when multiple entries are matched; the software programmable module 300 is further configured to obtain the routing rule information of the first CAN message, perform switch exchange processing on the first CAN message according to the routing rule information to obtain the second CAN message, and update the first CAN message in RAM to the second CAN message.

[0057] In this embodiment, the hardware forwarding module 200 extracts key information from the first CAN message. This key information includes the CAN controller's channel number and common attributes of the message, such as specific fields of the message itself. Then, it constructs a key using this key information. In this embodiment, the key extraction rules are not limited and can be flexibly configured according to the actual application. The key is extracted from the first CAN message according to the configured rules and assembled into the final key. This key will serve as the basis for the routing query module 500 to look up the routing table, determining how the CAN message should be processed and forwarded. The routing query module 500 performs a route lookup based on the key and returns the routing rule information of the first CAN message to the software programmable module 300. The software programmable module 300 then performs a switch operation on the first CAN message according to the routing rule information.

[0058] In some embodiments, the information carried in the routing lookup request further includes: the buffer ID of the first CAN message stored in RAM; the software programmable module 300 performs switch processing on the first CAN message by performing switch processing on the first CAN message according to the buffer ID. In this embodiment, the routing lookup request initiated by the hardware forwarding module 200 carries not only the key value, but also the buffer ID of the first CAN message stored in RAM. This additional information will be passed to the software programmable module 300, which can accurately read the corresponding first CAN message from RAM using the buffer ID, and perform further switch processing on the first CAN message based on the routing lookup result.

[0059] In one application example Figure 3 A schematic diagram of the route lookup module 500 shown in an exemplary embodiment of this application is illustrated. Figure 3 As shown, the routing lookup module 500 includes: multiple search engine units, two first-in-first-out (FIFO) input units (in h_fifo and in n_fifo), a priority decoder unit, and two FIFO output units (out h_fifo and out n_fifo).

[0060] Specifically, in the two input FIFO units (in h_fifo and in n_fifo), in n_fifo is a regular FIFO input unit, and in h_fifo is a priority FIFO input unit used to store information such as the key value to be matched and the buffer ID. The FIFO acts as a data buffer, ensuring that data can enter the subsequent search process in an orderly manner. When both FIFO input units have entries simultaneously, the entries in in h_fifo are processed first. This ensures that urgent or important search needs are prioritized, improving the system's response speed to critical information.

[0061] The search engine unit implements three matching modes: exact match, mask match, and range match. Exact match is used to find routing rules that are exactly the same as the key; mask match allows for more flexible matching by omitting certain bits of the key; and range match allows for finding routing rules whose key values ​​fall within a specific range. These rich matching modes can meet the routing lookup needs of different scenarios.

[0062] The priority decoder unit selects the first matched entry when multiple entries are matched and reports the matching result. This ensures that the system can quickly determine a clear routing rule even with multiple matching results. When a match is not found, the matching information is also written to two FIFO output units and reported.

[0063] Of the two FIFO output units (out h_fifo and out n_fifo), out n_fifo is a normal FIFO output unit, and out h_fifo is a priority FIFO output unit, used to store information such as the matched routing rule index, match status, routing result, and buffer ID. After matching is completed, an interrupt message is reported to the acceleration device.

[0064] To provide faster search efficiency, one application example configured 12 search engine units, 12 parallel search paths, and a valid entry threshold control mechanism. Users submit entries, which are evenly distributed among the 12 search engine units in sequence. Each search engine unit is configured with a current threshold (number of valid entries). The valid entry threshold significantly reduces search polling and scanning time, lowering search latency. For example, if a user configures 125 entries, engines 0-11 will each write 11 entries (threshold set to 11) and the remaining 7 engines will each write 10 entries (threshold set to 10). The 12 parallel engines poll based on the number of valid entries, greatly reducing processing latency.

[0065] In this application example, the route lookup module 500 achieves fast and efficient route lookup through an advanced lookup mechanism, providing key support for the message processing of the entire system.

[0066] In this embodiment, after obtaining the routing rule information of the first CAN message, the software programmable module 300 can perform switch processing on the first CAN message to obtain the second CAN message. In some embodiments, the switch processing includes at least one of the following: route resolution, message format conversion, message modification, message encapsulation, unicast or multicast processing, and message distribution management.

[0067] Specifically, the software programmable module 300 can parse the routing rules as needed based on the obtained routing rule information of the first CAN message, and perform protocol conversion between CAN and CAN FD messages for the message format of the first CAN message. Since CAN and CAN FD differ in data transmission rate, data length, etc., protocol conversion between CAN and CAN FD messages is implemented for the message format of the first CAN message to meet the communication needs between different devices or systems.

[0068] In addition, in some embodiments, the software programmable module 300 can also modify the first CAN message, for example, by modifying certain data fields or identifiers in the message to meet specific business requirements or communication protocol requirements.

[0069] In other embodiments, the software programmable module 300 can also perform encapsulation operations such as adding or modifying header information and checksum information on the first CAN message. For example, depending on different protocol conversion requirements, specific header fields of the CAN FD message can be added or modified, or the checksum field of the message can be updated to ensure the correctness and integrity of the message during transmission.

[0070] In other embodiments, the software programmable module 300 can also configure the transmission mode of the first CAN message to be unicast or multicast.

[0071] In other embodiments, the software programmable module 300 can also perform message distribution management on the first CAN message based on routing rules and system-defined priorities. For example, it can determine the message processing order, arrange which messages are sent first and which are sent later, and perform operations such as message storage and retrieval to enable quick location and processing of messages when needed.

[0072] In this embodiment, the message description information of the second CAN message mainly includes: key attributes of the second CAN message, such as the target address of the message, the channel information to which the message belongs, the buffer ID stored in RAM, the message direction, the message priority, etc. The acceleration device will decide how to process and send the second CAN message based on these message description information.

[0073] In some embodiments, the hardware forwarding module 200 retrieves the second CAN message from RAM according to the message description information and sends the second CAN message to the CAN transceiver in the following manner: determining the message scheduling priority and transmission processing method according to the message description information of the second CAN message, retrieving the second CAN message from RAM according to the message scheduling priority and transmission processing method, and sending the second CAN message to the CAN transceiver through the CAN controller. The CAN controller 100 establishes a physical connection and communication with the CAN bus through the CAN transceiver, and sends the second CAN message to the CAN bus through the CAN transceiver, thereby realizing the transmission of the second CAN message throughout the CAN network.

[0074] In some embodiments, the scheduling priority and transmission processing method of messages include at least one of the following: (1) Send messages using unicast or multicast methods; (2) Perform priority scheduling processing between or within CAN controller channels; (3) Perform concurrent processing on messages from different directions.

[0075] For the above method (1), the hardware forwarding module 200 obtains the target address of the message from the message description information and determines the message transmission processing method as unicast or multicast copy based on this information. When the message description information contains only one target address, it indicates that the message needs to be sent unicast. When the message description information contains multiple target addresses, it indicates that the message needs to be sent multicast. The second CAN message needs to be copied, and then the copied message is sent to the CAN controller 100 at the same time. The CAN controller 100 then sends the second CAN message to the CAN bus.

[0076] In the above method (2), the hardware forwarding module 200 obtains the channel information to which the message belongs and its priority between or within the channels of the CAN controller 100 from the message description information, and determines the scheduling priority of the message based on this information. It performs priority scheduling on multiple second CAN messages, taking into account both the priority of messages between different CAN controller channels (between PORTs) and the priority order of messages within the same CAN controller channel (within a PORT). For example, some urgent control command messages will be given higher priority and sent first.

[0077] For the above method (3), the hardware forwarding module 200 obtains the message direction from the message description information. The second CAN message contains messages in different directions, such as messages in the sending direction, receiving direction, and event direction. The hardware forwarding module 200 can determine the parallel transmission processing method of the message based on this information, and simultaneously process these second CAN messages in different directions concurrently to ensure that the system can efficiently process various types of messages and improve the overall communication efficiency.

[0078] In this embodiment, after determining the scheduling priority and transmission processing method of the message, the hardware forwarding module 200 can accurately retrieve the corresponding second CAN message from RAM 400 based on relevant information in the message description information (such as the buffer ID of the second CAN message stored in RAM), and write it into the corresponding CAN controller 100 channel according to the message scheduling priority and transmission processing method. For example, if the message description information indicates that a certain message is a high-priority unicast message to be sent to a specific CAN controller (specific channel number), this second CAN message can be marked as high priority and its unicast processing method can be determined. Then, the message content can be retrieved according to the buffer ID stored in RAM and written into the CAN controller channel corresponding to the specific channel number. As another example, if there are multiple second CAN messages from different channels (PORTs), after determining their priority and message direction through the message description information, the acceleration device can prioritize the high-priority messages, plan which messages can be processed concurrently and which need to be processed sequentially, and then retrieve the corresponding second CAN messages from RAM in sequence and write them into the CAN controller. Therefore, the retrieved second CAN message can be written into each CAN controller for transmission more efficiently according to the message scheduling priority and transmission processing method, reducing processing time and resource waste, and making the entire transmission process more orderly and efficient.

[0079] In some embodiments, the software programmable module 300 is further configured to acquire exception messages, perform aggregation processing on the exception messages through software coding, and send the aggregated exception messages to the main processor via an interrupt.

[0080] In this embodiment, the CAN controller may detect various abnormal situations during operation, such as bus errors and message errors; the hardware forwarding module 200 may also encounter hardware failures or other abnormal events. After receiving the abnormal messages, the software programmable module 300 performs aggregation processing on these messages through software encoding. In some embodiments, aggregation processing includes, but is not limited to, merging and analyzing multiple similar or related abnormal messages, and extracting key information. After aggregation processing, the software programmable module 300 sends the aggregated abnormal messages to the main processor for processing via interrupts (int) according to certain rules.

[0081] In some embodiments, such as Figure 2 As shown, the CAN acceleration device provided in this embodiment also includes an interrupt module 600, which provides interrupt services to the hardware forwarding module 200, the software programmable module 300, and the main processor for exchanging information and reporting interrupts.

[0082] In the CAN message fast forwarding method and CAN acceleration device provided in this embodiment, the CAN acceleration device is located between the main processor CPU and the CAN transceiver to realize CAN traffic offloading of the main processor. Functions requiring high performance and high power consumption, such as CAN message reception and transmission, are performed by the hardware forwarding module, while the switch processing required for messages is implemented by the software programmable module. This not only improves CAN forwarding performance but also flexibly supports CAN traffic offloading and switch functions in various scenarios, effectively reducing CAN forwarding latency and greatly improving CAN communication performance.

[0083] Figure 4 A structural block diagram of an electronic device 1000 illustrating an exemplary embodiment of this application is shown. The electronic device 1000 can be implemented as the aforementioned optical transmission power compensation device, which can be configured in electronic devices such as smartphones, tablets, laptops, desktop computers, smartwatches, televisions, or servers.

[0084] Typically, electronic device 1000 includes a processor 1001 and a memory 1002.

[0085] Processor 1001 may include one or more processing cores, such as a quad-core processor, a deca-core processor, etc. Processor 1001 may be implemented using at least one hardware form selected from DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). Processor 1001 may also include a main processor and a coprocessor. The main processor, also known as a CPU (Central Processing Unit), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, processor 1001 may integrate a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the screen. In some embodiments, processor 1001 may also include an AI (Artificial Intelligence) processor, which is used to handle computational operations related to machine learning.

[0086] The memory 1002 may include one or more computer-readable storage media, which may be non-transitory. The memory 1002 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices or flash memory devices. In some embodiments, the non-transitory computer-readable storage media in the memory 1002 is used to store at least one instruction, which is executed by the processor 1001 to implement all or part of the steps in the CAN message fast forwarding method shown in the method embodiments of this application.

[0087] Those skilled in the art will understand that Figure 4 The structure shown does not constitute a limitation on the electronic device 1000, and may include more or fewer components than shown, or combine certain components, or use different component arrangements.

[0088] In one exemplary embodiment, a readable storage medium is also provided, which stores a program or instructions that, when executed by a processor, implement all or part of the steps in the above-described CAN message fast forwarding method. For example, the computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a compact disc read-only memory (CD-ROM), magnetic tape, floppy disk, or optical data storage device, etc.

[0089] In one exemplary embodiment, a computer program product is also provided, comprising a computer program stored on a non-transitory computer-readable storage medium, the computer program including program instructions that, when executed by a computer, cause the computer to perform the aforementioned... Figure 1 All or part of the steps of the CAN message fast forwarding method shown in the embodiment.

[0090] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this application are indicated by the claims.

[0091] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.

Claims

1. A method for fast forwarding of CAN messages, characterized in that, include: The acceleration device acquires the first CAN message and stores the first CAN message in RAM according to a preset rule. The acceleration device is located between the main processor and the CAN transceiver. The acceleration device performs a switch operation on the first CAN message to obtain a second CAN message, updates the first CAN message in the RAM to the second CAN message, and obtains the message description information of the second CAN message. The acceleration device retrieves the second CAN message from the RAM according to the message description information and sends the second CAN message to the CAN transceiver.

2. The method according to claim 1, characterized in that, The first CAN message is obtained from the main processor CPU or the CAN transceiver.

3. The method according to claim 1, characterized in that, The first CAN message includes multiple channels; After the acceleration device acquires the first CAN message, and before storing the first CAN message into RAM according to a preset rule, the method further includes: The acceleration device performs priority scheduling processing on multiple first CAN messages between or within CAN controller channels, and performs concurrent processing on multiple first CAN messages from different directions.

4. The method according to claim 1, characterized in that, Before the acceleration device performs switch processing on the first CAN message, the method further includes: The acceleration device extracts key information from the first CAN message to construct a key value, initiates a route lookup request, and obtains the routing rule information of the first CAN message, wherein the information carried in the route lookup request includes the key value; The acceleration device performs switch processing on the first CAN message, including: The acceleration device performs switch processing on the first CAN message according to the routing rule information.

5. The method according to claim 1 or 4, characterized in that, The switch processing includes at least one of the following: Routing resolution, packet format conversion, packet modification, packet encapsulation, unicast or multicast processing, and packet distribution management.

6. The method according to claim 1, characterized in that, The acceleration device retrieves the second CAN message from the RAM according to the message description information and sends the second CAN message to the CAN transceiver, including: The acceleration device determines the scheduling priority and transmission processing method of the message based on the message description information of the second CAN message, retrieves the second CAN message from the RAM according to the scheduling priority and transmission processing method of the message, and sends the second CAN message to the CAN transceiver through the CAN controller.

7. The method according to claim 6, characterized in that, The scheduling priority and transmission processing method of the message include at least one of the following: Messages can be sent using unicast or multicast methods; Perform priority scheduling processing between or within CAN controller channels; Concurrent processing of messages from different directions.

8. The method according to claim 3, characterized in that, After the acceleration device initiates a route lookup request and before obtaining the routing rule information of the first CAN message, the method further includes: The acceleration device uses a mechanism that uses multiple search engines to search in parallel and configures the entry threshold for each search engine. It performs routing lookup based on the key value. If multiple entries are matched, the first matched entry is selected as the routing rule information for the first CAN message.

9. The method according to claim 1, characterized in that, The method further includes: The acceleration device acquires abnormal messages, performs aggregation processing on the abnormal messages through software coding, and sends the aggregated abnormal messages to the main processor via an interrupt.

10. A CAN acceleration device, characterized in that, The acceleration device is located between the main processor CPU and the CAN transceiver. The CAN acceleration device includes: a CAN controller, a hardware forwarding module, a software programmable module, and RAM, wherein: The hardware forwarding module is used to acquire the first CAN message and store the first CAN message in RAM according to a preset rule; The software programmable module is used to perform switch exchange processing on the first CAN message to obtain the second CAN message, update the first CAN message in the RAM to the second CAN message, and obtain the message description information of the second CAN message; The hardware forwarding module is further configured to retrieve the second CAN message from the RAM according to the message description information, and send the second CAN message to the CAN transceiver through the CAN controller; The CAN controller is used to send the second CAN message to the CAN transceiver.

11. The CAN acceleration device according to claim 10, characterized in that, Also includes: The routing query module includes: The hardware forwarding module is further configured to extract key information from the first CAN message after acquiring the first CAN message, construct a key value, and initiate a route lookup request, wherein the information carried in the route lookup request includes the key value; The routing query module is used to receive the routing lookup request, perform routing lookup based on the key value by using a mechanism of parallel search by multiple search engines and configuring the entry threshold of each search engine, and select the first matched entry to return the routing rule information of the first CAN message when multiple entries are matched. The software programmable module is further configured to obtain the routing rule information of the first CAN message, perform switch processing on the first CAN message according to the routing rule information to obtain the second CAN message, and update the first CAN message in the RAM to the second CAN message.

12. An electronic device, characterized in that, The electronic device includes a processor and a memory, the memory storing programs or instructions that can run on the processor, the programs or instructions being executed by the processor to implement the steps of the CAN message fast forwarding method as described in any one of claims 1 to 9.

13. A readable storage medium, characterized in that, The readable storage medium stores a program or instructions that, when executed by a processor, implement the steps of the CAN message fast forwarding method as described in any one of claims 1 to 9.

14. A computer program product comprising a computer program stored on a non-transitory computer-readable storage medium, the computer program comprising program instructions that, when executed by a computer, cause the computer to perform the steps of the CAN message fast forwarding method as described in any one of claims 1 to 9.