A method and device for converting logical representation based on network programming language

By performing syntax analysis and structural conversion on the P4 language, a logical resource management library is constructed, which solves the difficulty of IR mapping caused by the complexity of intermediate representations, improves the portability and scalability of data plane programs, and simplifies the P4 programming process.

CN118426752BActive Publication Date: 2024-09-13ZHEJIANG LAB
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410866695.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-01
Publication Date
2024-09-13
Estimated Expiration
2044-07-01

AI Technical Summary

Technical Problem

In the existing technology, the complexity of intermediate representation is high in modern networks, which makes it difficult to map IR to the backend of a specific target. The portability and scalability of data plane programs are poor, and it is difficult to support emerging transport protocols and flexible stack levels. structure.

Method used

By performing P4 syntax analysis on the network programming language P4 program code or intermediate representation, the network programming language logical structure is obtained, and based on this, a logical resource management library is constructed, and structural conversion is performed to model the logical association between network programming logical resources and realize IR Compiler development of backends mapped to specific targets.

Benefits of technology

It improves the efficiency of back-end mapping of IR to specific targets, reduces the difficulty for users to use network data processing chips for network programmability, enhances the portability and scalability of data plane programs, and simplifies the P4 programming process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118426752B
    Figure CN118426752B
Patent Text Reader

Abstract

The present invention discloses a conversion method and device based on the logical representation of a network programming language, the method comprising the following steps: performing P4 syntax parsing on a network programming language P4 program code or its intermediate representation to obtain a network programming language logical structure and multiple categories of network programming logical resources; arranging the network programming logical resources according to the categories to obtain a network programming logical resource management library, and classifying and recording the network programming logical resources; performing structural conversion on the network programming logical resources based on the network programming language logical structure to obtain a network programming logical representation, so as to model the logical association relationship between the network programming logical resources in the network programming logical resource management library. The present invention can convert a general network programming language or an intermediate representation of a general network programming language into a logical resource management library and a corresponding logical representation, which is helpful for quickly developing a compiler program for a backend that maps IR to a specific target, and improving work efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of network programming, and in particular relates to a conversion method and device based on logical representation of a network programming language. Background Art

[0002] With the development of multimodal networks, the development of multiple network modes customized by users is growing rapidly and is still in the ascendant. Since traditional network architectures often use fixed, hard-coded network functions, they cannot meet users' needs for customized services. It has become a consensus among researchers and manufacturers in the industry to realize the rapid and efficient deployment of multiple network modes in a unified network infrastructure through a programmable network platform. At the same time, facing various complex network modes, the network platform must take into account the definable programmability of various functions such as computing, storage, and forwarding. A single architecture is difficult to meet various functions including computing, storage, and forwarding. Therefore, the design of the network platform requires not only close cooperation between hardware and software, but also requires the platform to support multiple programming languages ​​and tools so that users can choose the appropriate programming languages ​​and tools for development according to their needs.

[0003] In terms of network programming languages, P4, as an emerging protocol-independent programmable packet processor high-level language, has received extensive attention. The application design of multimodal networks is inseparable from excellent network programming languages. Through the P4 language, programmers can define their own network protocols and customize network functions. Programs written in the P4 language are converted into target-specific representations through the P4 compiler, which makes the P4 language highly flexible and scalable. The P4 compiler consists of two parts: the front end that converts the P4 code into an intermediate representation (IR) and the back end that maps the IR to a specific target. This layered design enables the P4 compiler to support multiple target platforms, including hardware and software platforms. At the same time, the P4 compiler also provides a wealth of programming interfaces and tools, allowing programmers to easily write and debug P4 programs.

[0004] Although the P4 language brings a lot of convenience to network programming, there are still some challenges in practical applications. One of the biggest challenges is the programming of middleware. Intermediate representation plays a vital role in modern networks. It is responsible for handling tasks such as packet forwarding and routing in the network. However, due to the extremely high complexity of the intermediate representation, it brings many difficulties and challenges to the backend of IR mapping to a specific target. Programming it to support emerging transmission protocols and flexible stack hierarchies is still a daunting task. As mainstream vendors of switching equipment and chip ASICs implement programmability in their newly launched products (such as Broadcom's Trident-4, Intel / Barefoot's Tofino, and Cisco's Silicon One), programmable data planes have been moving towards deployment in data centers. However, current data plane programs are written in low-level, chip-specific languages ​​that are tightly coupled to chip-specific architectures, which leads to poor portability and scalability of data plane programs. To solve this problem, it is necessary to develop linking tools for different IR mappings to specific target backends in order to achieve flexible deployment and efficient operation of data plane programs. Summary of the invention

[0005] In view of the above, the purpose of the present invention is to provide a method and device for converting logical representations based on network programming languages, which can convert a general network programming language or its intermediate representation into a logical resource management library and a corresponding network programming logical representation, which helps to quickly develop a back-end compiler that maps IR to a specific target and improves work efficiency.

[0006] In order to achieve the above-mentioned invention object, the technical solution provided by the present invention is as follows:

[0007] An embodiment of the present invention provides a method for converting a logical representation based on a network programming language, comprising the following steps:

[0008] Perform P4 syntax parsing on the network programming language P4 program code or its intermediate representation to obtain the network programming language logic structure and multiple categories of network programming logic resources including header structure, structure body, parser parsing logic resources, control logic resources, table logic resources and action logic resources;

[0009] Arrange network programming logic resources according to categories to obtain a network programming logic resource management library, and classify, record and manage network programming logic resources through the network programming logic resource management library;

[0010] Based on the logical structure of the network programming language, the network programming logic resources are structurally transformed to obtain the network programming language P4 program code or its intermediate representation of the network programming logic representation, so as to model the logical association relationship between the network programming logic resources in the network programming logic resource management library.

[0011] Preferably, the P4 syntax parsing includes: header structure syntax parsing, structure conversion syntax parsing, parser logic segment syntax parsing and control module syntax parsing, wherein the control module syntax parsing includes table logic segment syntax parsing and action logic segment syntax parsing.

[0012] Preferably, a P4 syntax parsing tool or an intermediate representation parsing tool is used to perform P4 syntax parsing on the network programming language P4 program code or its intermediate representation, wherein the P4 syntax parsing tool includes a lexical parser and a syntax tree generator, and the intermediate representation parsing tool includes an intermediate representation text parser and a syntax tree transformation generator.

[0013] Preferably, the network programming logic resource management library includes: a header structure resource library, a structure resource library, a parser parsing logic resource library, a control logic resource library, a table logic resource library and an action logic resource library, and each category of resource library contains descriptions of all relevant resources of the category in network programming;

[0014] The header structure resource library and the structure resource library include the variable element types and element names therein;

[0015] The parser parsing logic resource library includes the name of the current parser, the current parsing logic, the association indication of the previous parsing logic parser, the branch jump condition and the association indication of the next parsing logic parser corresponding to the branch jump condition;

[0016] The control logic resource library includes the name of the current control module, the association indication of the contained tables and the association indication of the actions;

[0017] The table logic resource library includes all matching table logic, matching keys corresponding to each table, matching methods and associated instructions for actions;

[0018] The action logic resource library includes all operation logic association instructions.

[0019] Preferably, the structure conversion includes: header structure conversion, structure body conversion, parser logic segment conversion, table matching conversion in the control module and action conversion in the control module;

[0020] Wherein, the head structure conversion includes the creation of head structure association units;

[0021] The structure conversion includes the creation of structure association units and the association of header structure indications;

[0022] Parser logic segment conversion includes parser logic parsing, header structure indication association and structure body indication association;

[0023] The table matching conversion in the control module includes the indication association of relevant structures and resources;

[0024] The action conversion in the control module includes the indication association of related structures and resources.

[0025] Preferably, the network programming logic representation includes: all parsed fields of the network programming language P4 program code or its intermediate representation and its basic representation units, wherein the basic representation unit includes field name, field value, field length, field structure, field parsing logic, field matching mode and field operation logic;

[0026] The network programming logic indicates that the fields are recorded and arranged in sequence based on the key value of each field, and indication points are added to the fields, and indication associations are established between the fields and the contents of the basic representation units through the indication points.

[0027] Preferably, the network programming logic representation is divided into three layers of structure representation, the first layer structure is the set of message items that need to be processed defined by the network programming language, the second layer structure is the information stored in each message, and the third layer structure is the information of each basic representation unit.

[0028] Preferably, each basic representation unit is a directed acyclic graph, and in a network programming scenario, a network programming logic representation is constructed by sequentially linking the basic representation units, and all graph structures of the current network programming logic are constituted by exhaustively enumerating the network programming logic representations in all network programming scenarios, wherein the network programming logic representations in a single scenario are independent of each other.

[0029] Preferably, the field name is the name of the current field in the network programming language;

[0030] The value of the field is a fixed and clear value of the current field in the network programming language;

[0031] The field length is the byte length of the current field defined in the network programming language;

[0032] The field structure is a structure associated with the position field parsed by the current parser, including a header structure and a structure. The structure uses a linked list pointer to represent the nested relationship of the fields, and the next level represents the outer structure of the nested structure.

[0033] The field parsing logic is the nested relationship of the parsing branch to which the current field belongs, the parsing path is the parsing part of the parser, and the parsing logic uses a linked list pointer to represent the nested relationship of the field parsing path, and the next level represents the outer parsing part of the nested parsing path;

[0034] The field matching method is a matching method of the current field as a key value with the key value in the network message, including exact matching, minimum matching and three-state matching;

[0035] The operation logic of the field is the matching association relationship between the current field as a key value and the table, including whether there is a field key value in the table that matches the field, the matching method between the field key value in the table and the field, and the operation logic after the field key value in the table successfully matches the field.

[0036] To achieve the above-mentioned purpose of the invention, the embodiment of the present invention also provides a conversion device based on the logical representation of a network programming language, comprising: a network programming grammar parsing module, a logical resource record management module and a network programming logical representation modeling module;

[0037] The network programming syntax parsing module is used to perform P4 syntax parsing on the network programming language P4 program code or its intermediate representation to obtain the network programming language logic structure and multiple categories of network programming logic resources including header structure, structure body, parser parsing logic resources, control logic resources, table logic resources and action logic resources;

[0038] The logic resource record management module is used to organize network programming logic resources according to categories to obtain a network programming logic resource management library, and classify and record the network programming logic resources through the network programming logic resource management library;

[0039] The network programming logic representation modeling module is used to perform structural transformation on network programming logic resources based on the network programming language logic structure to obtain the network programming language P4 program code or its intermediate representation of the network programming logic representation, so as to model the logical association relationship between network programming logic resources in the network programming logic resource management library.

[0040] Compared with the prior art, the present invention has the following beneficial effects:

[0041] The conversion method and device of the logical representation based on the network programming language of the present invention can obtain a network programming logic resource management library based on the P4 language and the corresponding network programming logic representation, so that engineers, researchers and developers can learn how to use P4 for programming more easily, reduce the difficulty of users using network data processing chips for network programming, and then quickly develop IR mapping to the back-end compiler of a specific target, thereby improving work efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0043] Figure 1 It is a flowchart of a conversion method based on a logical representation of a network programming language provided by an embodiment of the present invention;

[0044] Figure 2 It is a schematic diagram of the first layer structure of the network programming logic representation provided by an embodiment of the present invention;

[0045] Figure 3 It is a schematic diagram of the second layer structure of the network programming logic representation provided by an embodiment of the present invention;

[0046] Figure 4 It is a schematic diagram of the third layer structure of the network programming logic representation provided by an embodiment of the present invention;

[0047] Figure 5 is a schematic diagram of a parsing flow of a parser logic segment provided by an embodiment of the present invention;

[0048] Figure 6 It is a schematic diagram of the field search and matching process provided by an embodiment of the present invention;

[0049] Figure 7 It is a schematic diagram of a field matching process of a basic representation unit provided by an embodiment of the present invention;

[0050] Figure 8 It is a schematic diagram of the structure of a conversion device based on logical representation of a network programming language provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0051] To make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific implementation methods described herein are only used to explain the present invention and do not limit the scope of protection of the present invention.

[0052] The inventive concept of the present invention is: in view of the poor portability and scalability of data plane programs faced by the backend for mapping IR to a specific target in the prior art, an embodiment of the present invention provides a conversion method and device for logical representation based on a network programming language. Since a key step in P4 compilation is to find a feasible and effective mapping to map high-level P4 source code constructs to physical resources exposed by the underlying hardware while satisfying the data and control flow dependencies in the program, a logical representation conversion method based on the P4 language or its intermediate representation is redefined in an embodiment of the present invention. By mapping the code logic in a program developed in the P4 language to resources and converting it into a development logical representation suitable for backend conversion of mapping IR to a specific target, the efficiency of the backend of mapping IR to a specific target is improved.

[0053] Figure 1 FIG. 1 is a flow chart of a conversion method based on a logical representation of a network programming language provided by an embodiment of the present invention. Figure 1 As shown, the embodiment provides a conversion method based on a logical representation of a network programming language, comprising the following steps:

[0054] S1, perform P4 syntax parsing on the network programming language P4 program code or its intermediate representation to obtain the network programming language logical structure and multiple categories of network programming logic resources including header structure, structure, parser parsing logic resources, control logic resources, table logic resources and action logic resources.

[0055] Specifically, a P4 syntax parsing tool or an intermediate representation parsing tool is used to perform P4 syntax parsing on a network programming language P4 program code or its intermediate representation, and the P4 syntax parsing includes: header structure syntax parsing, structure conversion syntax parsing, parser logic segment syntax parsing, and control module syntax parsing, wherein the control module syntax parsing includes table logic segment syntax parsing and action logic segment syntax parsing. The network programming language logic structure and multiple categories of network programming logic resources including header structure, structure, parser parsing logic resources, control logic resources, table logic resources, and action logic resources are obtained by parsing.

[0056] In the embodiment, the P4 syntax parsing tool includes a lexical parser and a syntax tree generator, and the intermediate representation parsing tool includes an intermediate representation text parser and a syntax tree transformation generator.

[0057] S2, organizing the network programming logic resources according to categories to obtain a network programming logic resource management library, and classifying, recording and managing the network programming logic resources through the network programming logic resource management library.

[0058] Specifically, a network programming logic resource management library is constructed according to different categories of network programming logic resources, including: a header structure resource library, a structure resource library, a parser parsing logic resource library, a control logic resource library, a table logic resource library and an action logic resource library. The resources are stored in the intermediate representation structure of the universal language p4, and the network programming logic resources are classified, recorded and managed through the network programming logic resource management library.

[0059] The resource library of each category contains descriptions of all relevant resources of the category in network programming. Among them, the header structure resource library and the structure resource library include the variable element types and element names therein; the parser parsing logic resource library includes the name of the current parser, the current parsing logic, the association indication of the previous parsing logic parser, the branch jump condition and the association indication of the next parsing logic parser corresponding to the branch jump condition; the control logic resource library includes the current control module name, the association indication of the contained tables and the association indication of the actions; the table logic resource library includes all matching table logics, the matching keys corresponding to each table, the matching methods and the association indications of the actions; the action logic resource library includes all the operation logic association indications.

[0060] S3, based on the network programming language logic structure, the network programming logic resources are structurally transformed to obtain the network programming language P4 program code or its intermediate representation of the network programming logic representation, so as to model the logical association relationship between the network programming logic resources in the network programming logic resource management library.

[0061] Specifically, the network programming logic resources are structurally converted according to the network programming logic structure, and the structural conversion includes: header structure conversion, structure conversion, parser logic segment conversion, table matching conversion in the control module and action conversion in the control module, and finally the network programming language P4 program code or its intermediate representation is represented by the network programming logic representation method. Among them, the header structure conversion includes the creation of the header structure association unit; the structure conversion includes the creation of the structure association unit and the header structure indication association; the parser logic segment conversion includes the parser logic parsing, the header structure indication association and the structure indication association; the table matching conversion in the control module includes the indication association of the relevant structure and resources; the action conversion in the control module includes the indication association of the relevant structure and resources.

[0062] The network programming logic representation includes all parsed fields and basic representation units of the network programming language P4 program code or its intermediate representation, where the basic representation unit includes field name, field value, field length, field structure, field parsing logic, field matching method and field operation logic. The field name is the name of the current field in the network programming language; the value of the field is the fixed and clear value of the current field in the network programming language; the field length is the byte length defined in the network programming language for the current field; the field structure is the structure associated with the position field parsed by the current parser, including the header structure and the structure. The structure uses a linked list pointer to represent the nested relationship of the field, and the next level represents the outer structure of the nested structure; the field parsing logic is the nested relationship of the parsing branch to which the current field belongs, the parsing path is the parsing part of the parser, the parsing logic uses a linked list pointer to represent the nested relationship of the field parsing path, and the next level represents the outer parsing part of the nested parsing path; the field matching method is the matching method of the current field as a key value with the key value in the network message, including exact matching, minimum matching and three-state matching; the field operation logic is the matching association relationship between the current field as a key value and the table, including whether the field key value in the table matches the field, the matching method of the field key value in the table with the field, and the operation logic after the field key value in the table successfully matches the field.

[0063] The network programming logic indicates that the fields are recorded and arranged in sequence based on the key value of each field, and indication points are added to the fields, and indication associations are established between the fields and the contents of the basic representation units through the indication points.

[0064] The network programming logic representation is divided into three layers of structure representation. Figure 2 As shown, the first-level structure is the first-level set sum of message entries that need to be processed defined by the network programming language. The number is consistent with the number of messages to be processed exhaustively. It is stored in a set sum manner, where each message corresponds to multiple basic representation units. Figure 3 As shown, the second layer structure is the information of the basic representation units (such as basic representation unit 1, basic representation unit 2 and basic representation unit 3) stored in each message. This layer structure is stored in a linked list. Each node in each basic representation unit in the linked list is the name corresponding to each field in the message (such as name 1, name 2 or name 3). The connection relationship of each basic representation unit represents the progressive relationship of the parsing logic path of the basic representation unit. The connection relationship between nodes represents the connection relationship between the header structure, structure, parsing logic, operation logic, etc. Figure 4 As shown, the third layer structure is the information of each basic representation unit, including field name, field value, field length, field structure, field parsing logic, field matching method and field operation logic.

[0065] Each basic representation unit is a directed acyclic graph. In a network programming scenario, a network programming logic representation is constructed by linking the basic representation units in sequence. The network programming logic representations in all network programming scenarios are exhaustively enumerated to form all graph structures of the current network programming logic, where the network programming logic representations in a single scenario are independent of each other.

[0066] In the embodiment, when performing structure conversion, the parser logic segment conversion is first performed, and according to the parser logic segment syntax parsing result, the header structure conversion method and the structure body conversion method are associated to generate a network programming logic representation set and a main structure, and then according to the control module syntax parsing result including the table logic segment syntax parsing and the action logic segment syntax parsing, the generated network programming logic representation set and the main structure are reconstructed and mapped through the table matching conversion in the control module and the action conversion in the control module, and finally a complete network programming logic representation is generated. Specifically, it includes the following aspects:

[0067] S3.1, parser logic segment parsing. Figure 5 As shown, when the input is a network programming P4 program file written in the network programming language P4, the syntax parser is first used to perform syntax parsing on the parser logic segment. The parser logic segment is composed of parsing modules in different states, and each parsing module is composed of two parts: extracting the parsing field and state state jump. During the parsing of the parser logic segment, first find the parsing state named start. Start is a state that must exist for each parsing function. If there is no start, the parsing ends and an error is reported. If there is a start, execute the parsing logic of the parser, first find the parsing state of start, and start analyzing each statement. If the statement is a field parsing, perform a message header structure conversion or a message structure conversion on the field according to the field definition of the record, and then parse the next statement after the conversion. If there is no field parsing, further determine whether there is a jump branch. If the statement is a state state jump, that is, there is a jump branch, then find the message record of the current state according to the current intermediate representation record, copy each record of the current jump state, and add the jump state name to the parsing state name field. At the same time, assign values ​​to the fields of each record of the current state according to the value of the jump field. If there is no jump branch, the paragraph parsing ends.

[0068] S3.2, header structure conversion. In the parser parsing logic, if the statement is field parsing, according to the recorded field definition, query the header structure resource library of the message, and find the corresponding position in the network programming logic representation. According to the message header structure, if the current header structure is parsed, fill in the information of each field; if some fields of the current header structure are parsed, fill in the length, name, parsing status name and other information of the corresponding field.

[0069] S3.3, structure conversion. In the parser parsing logic, if the statement is field parsing, according to the recorded field definition, query the structure resource library of the message, and find the corresponding position in the network programming logic representation. According to the message structure, if the current structure is parsed, fill in the information of each field. If some fields of the current structure are parsed, fill in the length, name and parsing status name of the corresponding field. If the parsed field is a header structure, fill in all field information of the header structure according to the header structure conversion method.

[0070] S3.4, table matching conversion and action conversion in the control module. By parsing the table logic segment and action logic segment syntax in the control module of the network programming language P4 respectively, the corresponding field position is found in the network programming logic representation after parsing. After the accurate search, the table information and action actions of the network programming logic representation graph structure are logically filled, and the table and action actions in the control module are indicated and associated.

[0071] First, the table logic segment needs to be parsed. After the table logic segment syntax parsing is completed, the key value (key) is extracted. The key contains one or more description expressions, each expression includes fields and matching methods, and stores the field structure of the current key. If there are multiple key value fields in a table in the P4 program code, and the matching method of a field is an exact matching method, that is, the network programming logic indicates that the second-level structure must contain the key value field accurately to be considered a successful match; other fields are in an inexact matching method, that is, the network programming logic does not have to meet the condition of accurately containing the key value field, and the key value field is an optional field.

[0072] Then, perform a logical representation search, traverse each first-level logical representation, and search in the second-level logical representation to see if the field of the network programming logical representation unit matches the field and structure of the current key. In this step, the field search and matching process is as follows: Figure 6As shown, after parsing the syntax of the table logical segment and extracting the key of the table segment, the logical representation field search is performed. When searching for the logical representation field, first traverse the key to see if there are fields with exact matching methods. If there are fields with exact matching methods, search for the exact matching fields first, otherwise perform other matching searches. If all the exact matching fields are found in the second-level logical representation, the current second-level logical representation is consistent with the exact matching fields in the current key; otherwise, search for the next second-level logical representation. If all the exact matching fields are found, the next step is to perform a non-exact matching search. After the non-exact matching finds all the corresponding fields, the table of all qualified fields in the key is logically associated with the information; if the matching search fails, search for the next second-level logical representation. Until the logical representation search is completed.

[0073] The field matching process of the basic representation unit is as follows Figure 7 As shown, the fields of the basic representation unit are parsed and stored through network programming, and accurately matched with the key value fields in the table items. After the key value fields in the table items are parsed by the parameter fields and stored in the parameter structure, they are read and compared with the fields represented by the basic unit. On the premise that the field names are the same, the structures are compared layer by layer. First, the first-level structure is read. If the first-level structure of the basic representation unit field is the same as that of the key value field in the table item, the next-level structure is read to continue the comparison; if the structures do not match, the basic representation unit field fails to match the key value field in the table item. They are not the same field and cannot be associated. If the last-level structure is read and the structures are matched successfully, the basic representation unit field matches the key value field in the table item successfully.

[0074] After the precise match is successful, since other fields are inexact matches, the current second-layer logic representation is searched with the inexact matching fields in the key. After the match is successful, the content of the third-layer logic representation is updated, including the matching method and the operation logic after the field matching, and the association indication of the table. At the same time, the action is associated with the indication, and finally the network programming logic representation of the network programming language P4 program code or its intermediate representation is obtained to model the logical association relationship between the network programming logic resources in the network programming logic resource management library.

[0075] Through the above process, the three-layer logical representation of the network programming language can be obtained. By traversing the three-layer logical representation, replacing the process of syntax parsing and traversing the syntax tree, through the first-layer logical representation, the developer can accurately understand the characteristics of the message to be operated in the network programming language, and obtain the syntax parsing relationship, table item association relationship and operation logic relationship of the message. Through these relationships, configuration commands can be quickly obtained for programmable devices, reducing the process of syntax parsing and traversing the syntax tree.

[0076] In summary, a conversion method based on the logical representation of a network programming language is based on the general network programming language P4 or the intermediate representation of the network programming language P4, uses the P4 syntax parsing tool and the intermediate representation parsing tool, and realizes the logical representation modeling of the processing logic function of network programming and the table item representation through the method of network programming structure conversion. The network programming logical representation obtained after the conversion includes all the information and data of the original logic of the network programming, including all the parsing fields, parsing logic paths, field matching structures and lengths of the recorded messages, and the operations after matching, as well as the logical association of all information content related to the message. The conversion method based on the logical representation of the network programming language and the network programming logical representation enhance the portability and scalability of the data plane program faced by the backend of the IR mapping to a specific target, and enable engineers, researchers and developers to learn how to use P4 for programming more easily, and quickly develop the compiler program of the backend of the IR mapping to a specific target, further improving work efficiency.

[0077] Based on the same inventive concept, Figure 8 As shown, the embodiment of the present invention further provides a conversion device 800 based on the logical representation of a network programming language, including: a network programming grammar parsing module 810, a logical resource record management module 820 and a network programming logical representation modeling module 830.

[0078] Among them, the network programming syntax parsing module 810 is used to perform P4 syntax parsing on the network programming language P4 program code or its intermediate representation to obtain the network programming language logical structure and multiple categories of network programming logic resources including header structure, structure, parser parsing logic resources, control logic resources, table logic resources and action logic resources.

[0079] The logic resource record management module 820 is used to organize the network programming logic resources according to categories to obtain a network programming logic resource management library, and to classify, record and manage the network programming logic resources through the network programming logic resource management library.

[0080] The network programming logic representation modeling module 830 is used to perform structural transformation on network programming logic resources based on the network programming language logic structure to obtain the network programming language P4 program code or its intermediate representation of the network programming logic representation, so as to model the logical association relationship between network programming logic resources in the network programming logic resource management library.

[0081] It should be noted that the conversion device based on the logical representation of the network programming language provided in the above embodiment belongs to the same inventive concept as the conversion method based on the logical representation of the network programming language. The specific implementation process is detailed in the embodiment of the conversion method based on the logical representation of the network programming language, which will not be repeated here.

[0082] The specific implementation methods described above provide a detailed description of the technical solutions and beneficial effects of the present invention. It should be understood that the above is only the most preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, supplements and equivalent substitutions made within the scope of the principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A method for converting a logical representation based on a network programming language, characterized in that: The following steps are involved: Perform P4 syntax parsing on the network programming language P4 program code or its intermediate representation to obtain the network programming language logic structure and multiple categories of network programming logic resources including header structure, structure body, parser parsing logic resources, control logic resources, table logic resources and action logic resources; Arrange network programming logic resources according to categories to obtain a network programming logic resource management library, and classify, record and manage network programming logic resources through the network programming logic resource management library; The network programming logic resource management library includes: a header structure resource library, a structure resource library, a parser parsing logic resource library, a control logic resource library, a table logic resource library and an action logic resource library. Each category of resource library contains descriptions of all relevant resources of the category in network programming, wherein the header structure resource library and the structure resource library include the variable element type and element name therein, the parser parsing logic resource library includes the name of the current parser, the current parsing logic, the association indication of the previous parsing logic parser, the branch jump condition and the association indication of the next parsing logic parser corresponding to the branch jump condition, the control logic resource library includes the current control module name, the association indication of the contained tables and the association indication of the actions, the table logic resource library includes all matching table logics, the matching keys corresponding to each table, the matching methods and the association indication of the actions, and the action logic resource library includes all the operation logic association indications; Based on the logical structure of the network programming language, the network programming logic resources are structurally transformed to obtain the network programming language P4 program code or its intermediate representation network programming logic representation, so as to model the logical association relationship between the network programming logic resources in the network programming logic resource management library; the network programming logic representation includes: all parsed fields of the network programming language P4 program code or its intermediate representation and its basic representation unit, wherein the basic representation unit includes field name, field value, field length, field structure, field parsing logic, field matching method and field operation logic, the network programming logic representation records and arranges the fields in sequence according to the key value of each field, and at the same time, adds indication points in the field, and establishes indication association between the field and the content of the basic representation unit through the indication points, wherein the field name is the name of the current field in the network programming language, the field value is the fixed and clear value of the current field in the network programming language, and the field length is the current The byte length of the previous field defined in the network programming language, the field structure is the structure associated with the position field parsed by the current parser, including the header structure and the structure, the structure uses a linked list pointer to represent the nested relationship of the field, and the next level represents the outer structure of the nested structure, the field parsing logic is the nested relationship of the parsing branch to which the current field belongs, the parsing path is the parsing part of the parser, the parsing logic uses a linked list pointer to represent the nested relationship of the field parsing path, and the next level represents the outer parsing part of the nested parsing path, the field matching method is the matching method of the current field as a key value with the key value in the network message, including exact matching, minimum matching and three-state matching, the field operation logic is the matching association relationship between the current field as a key value and the table, including whether there is a field key value in the table that matches the field, the matching method of the field key value in the table with the field, and the operation logic after the field key value in the table successfully matches the field; The network programming logic representation is divided into three-layer structure representation, the first layer structure is the set and of message items that need to be processed defined by the network programming language, the second layer structure is the information stored in each message, and the third layer structure is the information of each basic representation unit, wherein each basic representation unit is a directed acyclic graph, and in a network programming scenario, a network programming logic representation is constructed by sequentially linking the basic representation units, and all graph structures that constitute the current network programming logic are exhaustively enumerated for the network programming logic representations in all network programming scenarios, wherein the network programming logic representations in a single scenario are independent of each other.

2. The method for converting a logical representation based on a network programming language according to claim 1, characterized in that: The P4 syntax parsing includes: header structure syntax parsing, structure conversion syntax parsing, parser logic segment syntax parsing and control module syntax parsing, wherein the control module syntax parsing includes table logic segment syntax parsing and action logic segment syntax parsing.

3. The method for converting a logical representation based on a network programming language according to claim 1 or 2, characterized in that: A P4 syntax parsing tool or an intermediate representation parsing tool is used to perform P4 syntax parsing on the network programming language P4 program code or its intermediate representation, wherein the P4 syntax parsing tool includes a lexical parser and a syntax tree generator, and the intermediate representation parsing tool includes an intermediate representation text parser and a syntax tree conversion generator.

4. The method for converting a logical representation based on a network programming language according to claim 1, characterized in that: The structural conversion includes: header structure conversion, structure body conversion, parser logic segment conversion, table matching conversion in the control module and action conversion in the control module; Wherein, the head structure conversion includes the creation of head structure association units; The structure conversion includes the creation of structure association units and the association of header structure indications; Parser logic segment conversion includes parser logic parsing, header structure indication association and structure body indication association; The table matching conversion in the control module includes the indication association of relevant structures and resources; The action conversion in the control module includes the indication association of related structures and resources.

5. A conversion device based on logical representation of network programming language, characterized in that: include: Network programming syntax parsing module, logic resource record management module and network programming logic representation modeling module; The network programming syntax parsing module is used to perform P4 syntax parsing on the network programming language P4 program code or its intermediate representation to obtain the network programming language logic structure and multiple categories of network programming logic resources including header structure, structure body, parser parsing logic resources, control logic resources, table logic resources and action logic resources; The logic resource record management module is used to organize network programming logic resources according to categories to obtain a network programming logic resource management library, and classify and record the network programming logic resources through the network programming logic resource management library; The network programming logic resource management library includes: a header structure resource library, a structure resource library, a parser parsing logic resource library, a control logic resource library, a table logic resource library and an action logic resource library. Each category of resource library contains descriptions of all relevant resources of the category in network programming, wherein the header structure resource library and the structure resource library include the variable element type and element name therein, the parser parsing logic resource library includes the name of the current parser, the current parsing logic, the association indication of the previous parsing logic parser, the branch jump condition and the association indication of the next parsing logic parser corresponding to the branch jump condition, the control logic resource library includes the current control module name, the association indication of the contained tables and the association indication of the actions, the table logic resource library includes all matching table logics, the matching keys corresponding to each table, the matching methods and the association indication of the actions, and the action logic resource library includes all the operation logic association indications; The network programming logic representation modeling module is used to perform structural transformation on the network programming logic resources based on the network programming language logic structure to obtain the network programming language P4 program code or its intermediate representation network programming logic representation, so as to model the logical association relationship between the network programming logic resources in the network programming logic resource management library; the network programming logic representation includes: all parsed fields of the network programming language P4 program code or its intermediate representation and its basic representation unit, wherein the basic representation unit includes field name, field value, field length, field structure, field parsing logic, field matching method and field operation logic, the network programming logic representation records and arranges the fields in sequence according to the key value of each field, and at the same time adds indication points in the field, and establishes indication association between the field and the content of the basic representation unit through the indication points, wherein the field name is the name of the current field in the network programming language, and the value of the field is the fixed and clear value of the current field in the network programming language, The field length is the byte length of the current field defined in the network programming language, the field structure is the structure associated with the position field parsed by the current parser, including a header structure and a structure, the structure uses a linked list pointer to represent the nested relationship of the field, and the next level represents the outer structure of the nested structure, the field parsing logic is the nested relationship of the parsing branch to which the current field belongs, the parsing path is the parsing part of the parser, the parsing logic uses a linked list pointer to represent the nested relationship of the field parsing path, and the next level represents the outer parsing part of the nested parsing path, the field matching method is the matching method of the current field as a key value with the key value in the network message, including exact matching, minimum matching and three-state matching, the field operation logic is the matching association relationship between the current field as a key value and the table, including whether the field key value in the table matches the field, the matching method of the field key value in the table with the field, and the operation logic after the field key value in the table successfully matches the field; The network programming logic representation is divided into three-layer structure representation, the first layer structure is the set and of message items that need to be processed defined by the network programming language, the second layer structure is the information stored in each message, and the third layer structure is the information of each basic representation unit, wherein each basic representation unit is a directed acyclic graph, and in a network programming scenario, a network programming logic representation is constructed by sequentially linking the basic representation units, and all graph structures that constitute the current network programming logic are exhaustively enumerated for the network programming logic representations in all network programming scenarios, wherein the network programming logic representations in a single scenario are independent of each other.