A method for automatically generating network data forwarding surface driver code

By automatically generating the driver code for the network data forwarding plane, the lookup table metadata in the P4 code is extracted, table entries and data structures are generated, the table entries are initialized, and an operation programming interface is generated. This solves the problem of cumbersome driver code generation in the existing technology, improves development efficiency and code quality, and enhances the flexibility of network function design.

CN114995878BActive Publication Date: 2025-09-12SHENZHEN XINYUAN NETWORK TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202210633898.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-06
Publication Date
2025-09-12
Estimated Expiration
2042-06-06

AI Technical Summary

Technical Problem

Existing methods for automatically generating driver code are not suitable for automatically generating programmable forwarding plane drivers, or require a lot of modification to the logic of the automatically generated code, which is a cumbersome process.

Method used

By extracting the lookup table metadata in the P4 code, allocating space to generate the table entry starting address, generating the table entry and lookup table data structure, initializing the table entry and the table starting address, encapsulating the parameter data structure, generating the operation table entry API according to the lookup table algorithm type, automatically generating the operation programming interface, and associating the lookup algorithm text.

Benefits of technology

It simplifies the process from development to functional verification, saves human resources, improves development efficiency, improves code quality, supports existing and innovative network functions, increases the flexibility of network function design, and significantly shortens the time from R&D to functional verification.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114995878B_ABST
    Figure CN114995878B_ABST
Patent Text Reader

Abstract

The present invention provides a method for automatically generating driver code for a network data forwarding plane, comprising the following steps: S1: extracting metadata of a lookup table in P4 code; S2: allocating space for the lookup table and generating a table entry start address; S3: generating table entries and a lookup table data structure in the software driver code based on the lookup table metadata; S4: initializing table entries and the table start address of a global lookup table and encapsulating a parameter data structure; S5: generating a lookup algorithm body based on the algorithm type of the lookup table and automatically generating an operation table entry API; S6: generating an operation programming interface for each lookup table and associating it with the lookup algorithm body. The present invention automatically generates compatible driver code, simplifies the process from development to functional verification, eliminates the need for manual adaptation, conserves valuable company human resources, and improves development efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of programmable network data forwarding planes, and in particular to a method for automatically generating network data forwarding plane driver codes. Background Art

[0002] P4 is a protocol-independent packet processing programming language commonly used in network data forwarding plane functional design to implement network programmability and improve network flexibility. After developers complete functional design using P4, they use the front-end compiler to generate an IR file and a P4info file. The IR file is an intermediate file that the back-end compiler uses to generate the bit file for hardware. The IR file is also referred to as the intermediate file. The P4info file is an information file that describes lookup table information, execution actions, and other information. The P4info file is also referred to as the information file.

[0003] In an SDN (Software Defined Network) network, the controller loads the P4info file, identifies all descriptive information for each lookup table, and issues control information through the programming interface provided by the P4 Runtime, enabling flexible configuration of P4 devices. These operation APIs (Application Programming Interfaces) transmit generic data in a data exchange format that conforms to the protobuf protocol. However, when the P4 target device being operated is an FPGA, ASIC, or other implementation, since the P4 Runtime does not explicitly define or implement a specific software driver, connecting to a lookup table entry for configuring the P4 implementation requires implementing the relevant driver based on the P4 program. This software driver includes operations such as adding, modifying, retrieving, and deleting each lookup table entry.

[0004] Among them, Protobuf (Protocol Buffers) is a language-independent, platform-independent, extensible, lightweight and efficient serialization structure data format developed by Google. It is used to serialize custom data structures into byte streams and deserialize byte streams into data structures.

[0005] Existing methods for automatically generating driver code, such as CN201210497957.2, CN201810629021.8, CN201110432630.2, and CN201710813453.X, are not suitable for automatically generating programmable forwarding plane drivers or require extensive modifications to the automatically generated code logic, making the process cumbersome. We propose a method for parsing and automatically generating driver code from P4 code. Summary of the Invention

[0006] The object of the present invention is to provide a method for automatically generating network data forwarding plane driver code, which can automatically generate adaptive driver code and simplify the process from development to function verification.

[0007] The present invention provides a method for automatically generating network data forwarding plane driver code, comprising the following steps:

[0008] S1: Extract meta-information of the lookup table in the P4 code;

[0009] S2: Allocate space for the lookup table and generate the starting address of the table entry;

[0010] S3: Generate table entries and lookup table data structures in the software driver code based on the metadata of the lookup table. The table entry generation process is specifically as follows: traverse all fields in the table, and splice or split the fields according to the order and bit width of the fields to ensure 4-byte alignment. When the last field does not meet the 4-byte width, use a placeholder field to fill it to ensure alignment; for each generated lookup table data structure, create a global variable of this lookup table data structure type, and initialize the starting address and all table entries of the global variable according to the description information of the lookup table; according to the metadata of the lookup table, encapsulate the parameters to be passed according to the parameter type to generate the corresponding encapsulated parameter data structure;

[0011] S4: Initialize the table entries and the starting address of the global lookup table, and encapsulate the parameter data structure;

[0012] S5: Generate the lookup algorithm text based on the lookup table algorithm type and automatically generate the table entry operation API, including operations such as obtaining, adding, and deleting table entries;

[0013] S6: Generate an operation programming interface for each lookup table and associate it with the search algorithm text; generate multiple operation programming interfaces for each lookup table, including adding table items, deleting table items, and obtaining table items, and generate an operation programming interface for each lookup table; the specific method of associating the search algorithm text is: based on the algorithm type of the lookup table, generate a search algorithm text that is consistent with the hardware lookup table, this time generating an exact matching search text, generate an API function for the operation table item, and associate the operation API function with the search algorithm text.

[0014] Furthermore, the P4 code is compiled by a P4 compiler, which includes a front-end compiler and a back-end compiler. The front-end compiler compiles the P4 code to generate an intermediate file. The back-end compiler uses the intermediate file as input to compile and generate a hardware bit file used by the hardware, and automatically generates the corresponding software driver code. The intermediate file contains the lookup table information of the P4 code and the information file of the execution action.

[0015] Furthermore, the specific method of step S1 is: the back-end compiler uses the intermediate file as the input source to parse the metadata of each lookup table in the intermediate file. The metadata of the table includes the name of the table, the size of the lookup table, the field name, the bit width of each field, the type of each field and the algorithm type of the lookup table.

[0016] Furthermore, the intermediate file is an IR intermediate file.

[0017] Furthermore, the specific method of step S2 is: when the back-end compiler generates the hardware bit file, a physical space is allocated to each lookup table. This physical space consists of a physical starting address and a length. This physical starting address is the starting address of the table. The starting address of the lookup table and the metadata of the lookup table parsed in step S1 constitute the complete lookup table description information.

[0018] Furthermore, the specific method of step S3 is: for each lookup table description information, a corresponding lookup table data structure is generated; the lookup table description information and the lookup table data structure are in a one-to-one correspondence, and the lookup table data structure defines the table entries and the starting address of the lookup table; wherein the table entries define all the meta-information of the lookup table.

[0019] Furthermore, the process of generating table entries is as follows: traversing all fields in the table, splicing or splitting the fields according to the order of the fields and the bit width of the fields to make them meet 4-byte alignment. When the last field does not meet the 4-byte width, a placeholder field is used to fill it to make it meet the alignment.

[0020] Furthermore, for each lookup table data structure generated in step S3, a global variable of this lookup table data structure type is created, and the starting address and all table entries of the global variable are initialized according to the description information of the lookup table; according to the metadata of the lookup table, the parameters to be passed are encapsulated according to the parameter type to generate the corresponding encapsulated parameter data structure.

[0021] Furthermore, the lookup table is a layer-2 lookup table, wherein the lookup keyword of the lookup table is the destination MAC address of the network data packet, and the algorithm type of the lookup table is exact matching; a forwarding operation is performed on data packets that match the lookup table entry, and a discard operation is performed on unmatched data packets; the specific method for "generating table entries in the software driver code based on the metadata of the lookup table" in step S3 is: based on the metadata of the layer-2 lookup table, generate the software driver code and define the data structure type named as the layer-2 lookup table entry.

[0022] Furthermore, the specific method of "initializing the table entries and the starting address of the global lookup table" in step S4 is: based on the meta information of the second-layer lookup table, a data structure of the second-layer forwarding lookup table type is generated in the driver code.

[0023] Furthermore, the specific method of step S6 of "generating an operation programming interface for each lookup table and associating the search algorithm text" is: according to the algorithm type of the lookup table, generate a search algorithm text that is consistent with the hardware lookup table, this time generating an exact matching search text, generate an API function for the operation table item, and associate the operation API function with the search algorithm text.

[0024] The method of the present invention for automatically generating driver code for a network data forwarding plane automatically generates corresponding driver code, simplifies the process from development to functional verification, eliminates the manual adaptation process, saves the company's valuable human resources, and improves development efficiency; improves code quality, can automatically adapt to changes to the lookup table in the P4 code, and avoids unnecessary human coding errors during the manual adaptation process; supports existing network functions and innovative network functions, greatly improving the flexibility of network function design; can significantly shorten the time from research and development to functional verification, and improve product development efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] Hereinafter, some specific embodiments of the present invention will be described in detail in an exemplary and non-limiting manner with reference to the accompanying drawings. The same reference numerals in the accompanying drawings indicate the same or similar components or parts. It should be understood by those skilled in the art that these drawings are not necessarily drawn to scale. In the accompanying drawings:

[0026] Figure 1 This is a functional structure diagram of an embodiment of the present invention for automatically generating driver codes;

[0027] Figure 2 The present invention is a process diagram of a method for automatically generating network data forwarding surface driver code. DETAILED DESCRIPTION

[0028] The invention discloses a method for automatically generating network data forwarding surface driver code. The P4 language adopted in the invention is a protocol-independent data packet processing programming language.

[0029] like Figure 1 The figure shows the functional structure diagram of the driver code automatically generated by P4 code. P4 code is written in P4 language. P4 code is compiled by a P4 compiler. P4 compiler includes front-end compiler and back-end compiler. Developers use P4 language to design the function of network data forwarding interface. The front-end compiler compiles P4 code to generate IR intermediate file ( Figure 1 The back-end compiler uses the IR intermediate file as input to generate the hardware bit file used by the hardware and automatically generates the corresponding software driver code. The IR intermediate file contains information such as the P4 code lookup table information and execution actions.

[0030] In 2014, a Stanford University research team led by Nick McKeown published a paper in the SIGCOMM Computer Communication Review titled "P4: Programming Protocol-Independent Packet Processors." The paper proposed the P4 network programming language, primarily used on network devices such as network cards, switches, and routers, allowing users to program and control packet forwarding behavior on the data plane. After nearly a decade of development, the P4 language has become a de facto standard programming language for network applications. The P4 language is an open-source, specialized programming language for network behavior. Compared to circuit-level programming languages ​​like Verilog / VHDL, or general-purpose computing programming languages ​​like C / C++, P4 improves development efficiency for network applications by orders of magnitude.

[0031] The present invention provides a method for automatically generating network data forwarding surface driver code, such as Figure 2 As shown, the steps include:

[0032] S1: Extract meta-information of the lookup table in the P4 code;

[0033] The specific method of step S1 is: the back-end compiler uses the IR intermediate file as the input source and parses the metadata of each lookup table in the IR intermediate file. The metadata of the table includes the name of the table, the size of the lookup table, the field name, the bit width of each field, the type of each field, the lookup table algorithm and other table attributes.

[0034] S2: Allocate space for the lookup table and generate the starting address of the table entry;

[0035] When the back-end compiler generates the hardware bit file, a physical space is allocated for each lookup table. This physical space consists of a physical starting address and a length. This physical starting address is the starting address of the table. The starting address of the lookup table and the metadata of the lookup table parsed in step S1 constitute the complete lookup table description information.

[0036] S3: Generate table entries and lookup table data structures in the software driver code based on the metadata of the lookup table;

[0037] For each lookup table description, a corresponding lookup table data structure is generated. There is a one-to-one correspondence between the lookup table description and the lookup table data structure. The lookup table data structure defines the table entries, the starting address of the lookup table, and other information. The table entries define all metadata about the lookup table. The process of generating table entries involves traversing all fields in the table and concatenating or splitting them based on their order and width to ensure 4-byte alignment. If the last field does not meet the 4-byte width, a placeholder field is used to fill it to ensure alignment.

[0038] S4: Initialize the table entries and the starting address of the global lookup table, and encapsulate the parameter data structure;

[0039] For each lookup table data structure generated in step S3, a global variable of this lookup table data structure type is created, and the starting address and all table entries of the global variable are initialized according to the description information of the lookup table; according to the metadata of the lookup table, the parameters to be passed are encapsulated according to the parameter type to generate the corresponding encapsulated parameter data structure.

[0040] S5: Generate the search algorithm text according to the algorithm type of the search table;

[0041] Based on the algorithm type of the lookup table, a lookup algorithm text consistent with the hardware lookup algorithm is generated.

[0042] S6: Generate an operation programming interface for each lookup table and associate it with the main text of the lookup algorithm; generate multiple operation programming interfaces (APIs) for each lookup table, including adding a table entry, deleting a table entry, and obtaining a table entry.

[0043] The table entry operation API function parameters are the encapsulated parameter data structure generated in step S4. In the implementation of the table entry operation API code, since the fields may be segmented when defined in the data structure, it is necessary to perform appropriate shift operations on the passed fields based on the segmentation of the fields, associate the table entry operation API with the generated search algorithm body, and then assign a value to the table entry.

[0044] The lookup table in step S1 is a layer-2 lookup table named L2_fwd. Of course, the layer-2 lookup table L2_fwd is only an application example of the present invention. The present invention can be used for any lookup table, not just the layer-2 lookup table L2_fwd.

[0045] The Layer 2 lookup table L2_fwd uses the destination MAC address (MAC address, also known as the LAN address) of the network packet as the search key. The lookup table algorithm uses an exact match. Packets that match the lookup table entry are forwarded (L2_send_to_port), while packets that do not match are dropped (DROP). The lookup key, the destination MAC address, is 48 bits wide, the physical port number is 9 bits wide, and the lookup table contains 4096 entries.

[0046] The P4 code is as follows:

[0047] / / Lookup table L2_fwd definition

[0048] table L2_fwd{

[0049] / / Specify the search keyword as: destination MAC address

[0050] key={

[0051] hdr.eth.dmac:exact;

[0052] }

[0053] / / Perform forwarding (L2_send_to_port) operations on packets that match the lookup table entries, and discarding (DROP) operations on packets that do not match

[0054] actions={

[0055] L2_send_to_port;

[0056] drop;

[0057] }

[0058] / / The lookup table entry size is 4096

[0059] size=4096;

[0060] default_action=NoAction;

[0061] }

[0062] / / Drop action: forward the data packet to the port with the physical port number DROP_PORT, which means discarding the data packet

[0063] action drop(){

[0064] stdmeta.egress_port=DROP_PORT;

[0065] }

[0066] / / Forward action: forward the data packet to the port with the physical port number port_id, where port_id is the action parameter

[0067] action L2_send_to_port(bit <9> port_id){

[0068] stdmeta.egress_port=port_id;

[0069] }

[0070] The specific method of "generating an entry in the software driver code based on the metadata of the lookup table" in step S3 is as follows: based on the metadata of the second-layer lookup table L2_fwd, generate the software driver code and define the data structure type named as the second-layer lookup table entry L2_fwd_lookup_entry: typedef struct{

[0071] U32 key_dmac_1:32;

[0072] U32 key_dmac_2:16,action_port_id:9,action_code:2,table_valid:1,padding:4;}L2_fwd_lookup_entry;

[0073] The generated table item layout is intuitively represented as shown in Table 1:

[0074] Table 1 Table entry layout

[0075]

[0076] This table entry defines the first key field key_dmac_1, the second key field key_dmac_2, the third table validity field table_valid, the fourth action code field action_code, the fifth action parameter field action_port_id, and the sixth placeholder field padding. Since the lookup key dmac (destination MAC address) in the lookup table has a bit width of 48 bits and a length exceeding 32 bits, it needs to be split to meet the 4-byte alignment requirement. Therefore, a first key field key_dmac_1 with a bit width of 32 bits and a second key field key_dmac_2 with a bit width of 16 bits are generated. The first key field key_dmac_1 stores the lower 32 bits of dmac, and the second key field key_dmac_2 stores the upper 16 bits of dmac. The fifth action parameter field action_port_id stores the forwarding port number, which maps the parameter port_id of the forwarding action L2_send_to_port in the P4 code, so its bit width is 9 bits. The fourth action code field, action_code, maps to the forwarding action number in the P4 code. Since P4 defines three actions: drop (DROP), forward L2_send_to_port, and no action NoAction, the fourth action code field, action_code, is defined as 2 bits. The third table valid field, table_valid, is 1 bit wide and is automatically generated to indicate whether the current table entry is in use. Since the 16-bit second key field, key_dmac_2, the 9-bit fifth action parameter field, action_port_id, the 2-bit fourth action code field, action_code, and the 1-bit third table valid field, table_valid, use a total of 28 bits, a 4-bit sixth placeholder field, padding, is required.

[0077] The specific method of "initializing the table entries and the starting address of the global lookup table" in step S4 is as follows: based on the metadata of the Layer 2 lookup table L2_fwd, a data structure of the Layer 2 forwarding lookup table L2_fwd_lookup_fields type is generated in the driver code, where the entry depth of the table entry is 4096, which is consistent with the number of table entries defined in the metadata of the Layer 2 lookup table L2_fwd. The code is as follows:

[0078] typedef struct{

[0079] L2_fwd_lookup_entry entry

[4096] ;

[0080] U32 addr;

[0081] }L2_fwd_lookup_fields;

[0082] The field addr stores the starting address of the second-layer lookup table L2_fwd in physical memory. The code is as follows:

[0083] static L2_fwd_lookup_fields L2_fwd_lookup={

[0084] .entry={0},

[0085] .addr=0x8000+0x60000000,

[0086] };

[0087] Typically, P4's target hardware is connected to the operating system via the motherboard's PCIE interface. By establishing an address mapping, the driver can access and operate the hardware lookup table. When compiling P4 code, the configuration file specified by the configuration personnel is read, along with the relevant configuration information. The starting value of the mapping address used by the hardware is then configured. A Layer 2 forwarding lookup table named L2_fwd_lookup is defined using the L2_fwd_lookup_fields type. The table entries in this Layer 2 lookup table are initialized to all zeros. The starting address of this Layer 2 lookup table is initialized to the global starting address 0x60000000 plus an offset of 0x8000. The global address is 0x60000000, which is custom-specified in the configuration file. The offset of 0x8000 is the offset of the current lookup table from the global address. This offset is generated because the address space has been allocated to other lookup tables.

[0088] The backend compiler will allocate a space for each lookup table, so the starting address of each lookup table in the driver code needs to be added with the corresponding offset value.

[0089] The specific method of "generating the operation programming interface of each lookup table and the associated lookup algorithm text" in step S6 is:

[0090] Since the number of API parameters is limited, to meet programming specifications and improve the friendliness of API functions, the parameters are encapsulated by type. A data type named "L2_fwd_lookup_key" is generated, encapsulating the lookup keyword. The key field "key_dmac" corresponds to the lookup keyword destination MAC address in the P4 table entry. A data type named "L2_fwd_lookup_action" is generated, where the fifth action parameter field "action_port_id" corresponds to the parameter "port_id" of the L2_send_to_port forwarding action, and the fourth action code field "action_code" corresponds to the forwarding action number in the P4 code. Based on the algorithm type of the lookup table, a lookup algorithm text is generated that is consistent with the hardware lookup table. This time, an exact match lookup text is generated. An API function for the operation table entry is generated, and the operation API function and the lookup algorithm text are associated.

[0091] The above code is as follows:

[0092] / / Search for keyword structure definition in API

[0093] typedef struct{

[0094] U64 key_dmac;

[0095] }L2_fwd_lookup_key;

[0096] / / In the API, a structure describing the action corresponding to the table item

[0097] typedef struct{

[0098] U8 action_code;

[0099] U16 action_port_id;

[0100] }L2_fwd_lookup_action;

[0101] Generate three operation API functions for operating lookup table items, namely, configuring table items set_layer 2 forwarding lookup table items, deleting table items del_layer 2 forwarding lookup table items, and reading table items get_layer 2 forwarding lookup table items.

[0102] The above code is as follows:

[0103] / / Configuration table items

[0104] int set_L2_fwd_lookup_entry(L2_fwd_lookup_key lookupKey,

[0105] L2_fwd_lookup_action lookupAction);

[0106] / / Delete table entry

[0107] int del_L2_fwd_lookup_entry(L2_fwd_lookup_key lookupKey);

[0108] / / According to KEY, read the table items stored by the software

[0109] int get_L2_fwd_lookup_entry(L2_fwd_lookup_key lookupKey,

[0110] L2_fwd_lookup_action*lookupAction);

[0111] Technicians who use API for programming can directly use the above functions to complete operations such as adding, modifying, and deleting table entries.

[0112] The method of the present invention for automatically generating driver code for a network data forwarding plane automatically generates corresponding driver code, simplifies the process from development to functional verification, eliminates the manual adaptation process, saves the company's valuable human resources, and improves development efficiency; improves code quality, can automatically adapt to changes to the lookup table in the P4 code, and avoids unnecessary human coding errors during the manual adaptation process; supports existing network functions and innovative network functions, greatly improving the flexibility of network function design; can significantly shorten the time from research and development to functional verification, and improve product development efficiency.

[0113] At this point, those skilled in the art will recognize that, although a number of exemplary embodiments of the present invention have been shown and described in detail herein, many other variations or modifications consistent with the principles of the present invention may be directly determined or derived from the disclosure of the present invention without departing from the spirit and scope of the present invention. Therefore, the scope of the present invention should be understood and deemed to cover all such other variations or modifications.

Claims

1. A method for automatically generating network data forwarding interface driver code, characterized in that: The steps are as follows: S1: Extract meta-information of the lookup table in the P4 code; S2: Allocate space for the lookup table and generate the starting address of the table entry; S3: Generate table entries and lookup table data structures in the software driver code based on the metadata of the lookup table. The table entry generation process is specifically as follows: traverse all fields in the table, and splice or split the fields according to the order and bit width of the fields to ensure 4-byte alignment. When the last field does not meet the 4-byte width, use a placeholder field to fill it to ensure alignment; for each generated lookup table data structure, create a global variable of this lookup table data structure type, and initialize the starting address and all table entries of the global variable according to the description information of the lookup table; according to the metadata of the lookup table, encapsulate the parameters to be passed according to the parameter type to generate the corresponding encapsulated parameter data structure; S4: Initialize the table entries and the starting address of the global lookup table, and encapsulate the parameter data structure; S5: Generate the lookup algorithm text based on the lookup table algorithm type and automatically generate the table entry operation API, including table entry acquisition, addition, and deletion operations; S6: Generate an operation programming interface for each lookup table and associate it with the lookup algorithm text. Multiple operation programming interfaces are generated for each lookup table, including those for adding, deleting, and retrieving entries. The specific method for associating the lookup algorithm text is as follows: Based on the algorithm type of the lookup table, generate a lookup algorithm text that is consistent with the hardware lookup table. This time, an exact match is generated. Generate an API function for manipulating the table entries, and associate the API function with the lookup algorithm text. The specific method of step S2 is as follows: when the backend compiler generates the hardware bit file, a physical space is allocated for each lookup table. This physical space consists of a physical start address and a length. This physical start address is the start address of the table. The start address of the lookup table and the metadata of the lookup table parsed in step S1 constitute the complete lookup table description information; The specific method of step S3 is: for each lookup table description information, a corresponding lookup table data structure is generated; the lookup table description information and the lookup table data structure are in a one-to-one correspondence, and the lookup table data structure defines the table entry and the starting address of the lookup table; The table entry defines all the meta information of the lookup table.

2. The method for automatically generating network data forwarding interface driver code according to claim 1, characterized in that: The P4 code is compiled by a P4 compiler, which includes a front-end compiler and a back-end compiler. The front-end compiler compiles the P4 code to generate an intermediate file. The back-end compiler uses the intermediate file as input to compile and generate the hardware bit file used by the hardware, and automatically generates the corresponding software driver code. The intermediate file contains the P4 code lookup table information and the execution action information file.

3. The method for automatically generating network data forwarding interface driver code according to claim 2, characterized in that: The specific method of step S1 is: the back-end compiler uses the intermediate file as the input source and parses the metadata of each lookup table in the intermediate file. The metadata of the table includes the name of the table, the size of the lookup table, the field name, the bit width of each field, the type of each field and the algorithm type of the lookup table.

4. The method for automatically generating network data forwarding interface driver code according to claim 3, characterized in that: The intermediate file is an IR intermediate file.

5. The method for automatically generating network data forwarding plane driver code according to any one of claims 1 to 4, characterized in that: The lookup table is a Layer 2 lookup table, wherein the lookup keyword of the lookup table is the destination MAC address of the network data packet, and the algorithm type of the lookup table is exact match; a forwarding operation is performed on data packets that match the lookup table entry, and a discard operation is performed on data packets that do not match; the specific method for "generating table entries in the software driver code based on the metadata of the lookup table" in step S3 is: based on the metadata of the Layer 2 lookup table, the software driver code is generated and a data structure type named as the Layer 2 lookup table entry is defined.

6. The method for automatically generating network data forwarding plane driver code according to any one of claims 1 to 4, characterized in that: The specific method of "initializing the table entries and the starting address of the global lookup table" in step S4 is: based on the meta information of the second-layer lookup table, a data structure of the second-layer forwarding lookup table type is generated in the driver code.

Citation Information

Patent Citations

  • Interface automatic generating system and interface automatic generating method

    CN102520960A

  • Method and system for automatically generating code based on data model drive

    CN102968306A

  • Method for automatically generating driver codes according to chip manual

    CN107506228A

  • Automatic generation method and device for signal driving program code

    CN108829395A