Virtual function operation methods, electronic devices, and media based on logical identifiers
By establishing a mapping relationship between physical and logical identifiers in hardware resources, the software can be reused across multiple virtual functions, solving the problems of high software complexity and high communication costs, and improving operating efficiency.
Patent Information
- Application Number
- CN202511189635.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-25
- Publication Date
- 2025-11-14
- Estimated Expiration
- 2045-08-25
AI Technical Summary
In existing technologies, software cannot be reused when running on multiple virtual functions, resulting in high software complexity, high communication costs, and low operating efficiency.
By establishing a mapping relationship between physical and logical identifiers of hardware resources, the software can reuse these identifiers across multiple virtual functions, issuing commands directly through the logical identifiers, with the hardware completing the identifier conversion.
It reduces software complexity and communication costs, and improves the efficiency of software commands in virtual functions.
Smart Images

Figure CN120723230B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of chip technology, and in particular to a method for operating virtual functions based on logical identifiers, an electronic device, and a medium. Background Technology
[0002] Chips can partition hardware resources to form multiple virtual functions, and software can run independently on these virtual functions. In existing technologies, software needs to set up multiple branches, each requiring knowledge of the hardware resource partitioning corresponding to the virtual function. When issuing commands, the physical identifier of the corresponding hardware is used based on the different hardware resource partitioning. This prevents software reuse across multiple virtual functions, resulting in high software complexity, high communication costs, and low efficiency of software commands running on virtual functions. Therefore, improving software reusability across multiple virtual functions, thereby reducing software complexity and communication costs, and increasing the efficiency of software commands running on virtual functions, is a pressing technical problem that needs to be solved. Summary of the Invention
[0003] The purpose of this invention is to provide a method, electronic device, and medium for operating virtual functions based on logical identifiers, which reduces software complexity and communication costs, and improves the efficiency of software commands operating on virtual functions.
[0004] According to a first aspect of the present invention, a method for operating virtual functions based on logical identifiers is provided, comprising:
[0005] Step S1: Divide the hardware resources into M virtual functions {A1, A2, ..., A...} m ,...,A M}, A m For the m-th virtual function, where m ranges from 1 to M, A m ={B1 m B2 m ,...,B i m ,...,B f(m) m}, B i m For A m The corresponding i-th type of hardware resource, where i ranges from 1 to f(m), and f(m) is A m The total number of corresponding hardware resource types;
[0006] Step S2: Obtain each B i m The physical identifier {C1} corresponding to each hardware resource im C2 im ,...,C j im,...,C g(im) m}, C j im For B i m The physical identifier of the j-th hardware resource, where j ranges from 1 to g(im), and g(im) is B. i m The total number of hardware resources in the system;
[0007] Step S3: According to the preset logical identifier numbering order and each B i m The corresponding hardware resource type settings are configured for each B. i m The corresponding logical identifier {D1 im D2 im ,...,D j im ,...,D g(im) m}, D j im For B i m The physical identifier C of the j-th hardware resource j im The corresponding logical identifier, C j im and D j im The mapping relationship is recorded in the hardware;
[0008] Step S4: Load the software SW into A m A was obtained from m The corresponding software in SW m ;
[0009] Step S5, SW m Get each B i m The total number of corresponding hardware resources, g(im);
[0010] Step S6, SW m Based on D j im Issue the command, D j im No more than D g(im) im ;
[0011] Step S7: The hardware will process the corresponding D in each command. j im Convert to the corresponding C j im Execute the corresponding command.
[0012] According to a second aspect of the present invention, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being configured to perform the method described in the first aspect of the present invention.
[0013] According to a third aspect of the present invention, a computer-readable storage medium is provided, storing computer-executable instructions for performing the method described in the first aspect of the present invention.
[0014] Compared with existing technologies, this invention has significant advantages and beneficial effects. Through the above technical solution, the virtual function operation method, electronic device, and medium based on logical identifiers provided by this invention achieve considerable technological advancement and practicality, and have broad industrial application value. It has at least the following beneficial effects:
[0015] The hardware resource allocation in this invention is completely transparent to the software, allowing the software to be reused across multiple virtual functions without the need for separate software branches. This invention establishes a mapping between the physical and logical identifiers of each hardware resource, and the logical identifiers of the same hardware resource are set in the same order across different virtual functions. Therefore, the software only needs to obtain the available quantity of each type of hardware resource in the corresponding virtual function and directly issue instructions through the logical identifiers, without needing to know the physical identifiers corresponding to the specific hardware resources. This invention enables software reusability across multiple virtual functions, reduces software complexity and communication costs, and improves the efficiency of software commands running on virtual functions. Attached Figure Description
[0016] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 A flowchart of a virtual function operation method based on logical identifiers provided in an embodiment of the present invention. Detailed Implementation
[0018] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0019] This invention provides a method for operating virtual functions based on logical identifiers, such as... Figure 1 As shown, it includes:
[0020] Step S1: Divide the hardware resources into M virtual functions {A1, A2, ..., A...} m ,...,A M}, A m For the m-th virtual function, where m ranges from 1 to M, A m ={B1 m B2 m ,...,B i m ,...,B f(m) m}, B i m For A m The corresponding i-th type of hardware resource, where i ranges from 1 to f(m), and f(m) is A m The total number of corresponding hardware resource types.
[0021] It should be noted that after the hardware resources are partitioned, each virtual function has independent hardware resources. In step S1, M virtual functions can be partitioned based on all the hardware resources in the chip, or based on a portion of the hardware resources in the chip. The types and quantities of the same type of hardware resources partitioned in different virtual functions can be the same or different. When m takes different values, f(m) may be equal or unequal. The hardware resources may specifically include queues, computing units, storage space, etc.
[0022] Step S2: Obtain each B i m The physical identifier {C1} corresponding to each hardware resource im C2 im ,...,C j im ,...,C g(im) m}, C j im For B i m The physical identifier of the j-th hardware resource, where j ranges from 1 to g(im), and g(im) is B. i m The total number of hardware resources in China.
[0023] Step S3: According to the preset logical identifier numbering order and each B i m The corresponding hardware resource type settings are configured for each B. im The corresponding logical identifier {D1 im D2 im ,...,D j im ,...,D g(im) m}, D j im For B i m The physical identifier C of the j-th hardware resource j im The corresponding logical identifier, C j im and D j im The mapping relationship is recorded in the hardware.
[0024] It should be noted that the preset logical identifier numbering order is the same for different virtual functions of the same hardware resource. In one example, A1 is allocated 8 queues and 4 computing modules, and A2 is allocated 4 queues and 2 computing modules. Therefore, the logical identifiers of the 8 queues in A1 are set to q1, q2, q3, q4, q5, q6, q7, q8, respectively; the logical identifiers of the 4 computing modules in A1 are set to p1, p2, p3, p4, respectively; the logical identifiers of the 4 queues in A2 are set to q1, q2, q3, q4, respectively; and the logical identifiers of the 2 computing modules in A2 are set to p1, p2, respectively.
[0025] Step S4: Load the software SW into A m A was obtained from m The corresponding software in SW m .
[0026] It should be noted that the existing technology requires processing each A m Configure corresponding software branches. Each software branch needs to accurately obtain the physical identifier corresponding to each hardware resource it is assigned to. Commands are issued based on the physical identifiers. Each A m The corresponding physical identifiers are all different, therefore software reuse is impossible, and the software code is large and complex. In step S4 of this invention, since the logical identifier setting order of the same hardware resource is the same in different virtual functions, the logic of the software issuing commands based on the logical identifier is consistent. Therefore, the software can be reused in different virtual functions without setting corresponding branches for each virtual function. The software is directly loaded into A. m This reduces the amount and complexity of the software code.
[0027] Step S5, SW m Get each B i mThe total number of corresponding hardware resources, g(im).
[0028] It should be noted that each A m The amount of the same type of hardware resources allocated in the system may vary, therefore, SW is required. m Get each B i m The total number of corresponding hardware resources g(im), SW m Commands can be issued based on the logical identifier of hardware resources within the range of g(im), without needing to know the physical identifier corresponding to each hardware resource, thus reducing communication between software.
[0029] Step S6, SW m Based on D j im Issue the command, D j im No more than D g(im) im .
[0030] Step S7: The hardware will process the corresponding D in each command. j im Convert to the corresponding C j im Execute the corresponding command.
[0031] It should be noted that the execution of commands in the hardware is based on the physical identifier of the hardware resources, but the logical identifier and the conversion of the identifier are completed in the hardware without the involvement of the software, and the software is unaware of it.
[0032] It should be noted that all information directly communicating with the software, such as commands issued by the software and instructions received by the software, is implemented based on logical identifiers. Executing commands in the hardware is implemented based on physical identifiers. During command execution, if it is necessary to send instructions to the software or reply with a status message, the physical identifier of the hardware resource needs to be converted to a physical identifier. As one embodiment, step S7 includes:
[0033] Step S71, Hardware based on C j im During the execution of the corresponding command, if it is necessary to allocate resources to the SW based on hardware resources... m If a command is sent or a status is replied to, then C is obtained. j im The corresponding D j i Based on D j i Generate the corresponding command or response status and send it to the SW. m .
[0034] It should be noted that Cj im and D j i The mapping relationship is stored in the hardware, and the conversion process is also completed in the hardware without the need for software intervention. The software always interacts with the hardware based on the logical identifier.
[0035] As one embodiment, step S71 includes:
[0036] Step S711, Hardware based on C j im During the execution of the corresponding command, if C j im If an exception occurs, then exception C is retrieved. j im Corresponding exception D j i .
[0037] Among them, C j im Exceptions can specifically include computation module exceptions, queue exceptions, etc.
[0038] Step S712, based on exception D j i Generate an interrupt packet and send it to the switch. m .
[0039] When an interrupt is triggered due to a hardware resource malfunction, requiring the hardware resource to be stopped, as one embodiment, the step S712 is followed by:
[0040] Steps S713 and SW m Based on anomaly D j i The generator sends the command to stop the hardware resources from running.
[0041] Step S714: The hardware will stop the abnormal D in the operation of hardware resources. j i Convert to the corresponding exception C j im ;
[0042] Step S715, Stop exception C j im The operation of the corresponding hardware resources.
[0043] During operation, the chip may have one or more A... m In cases where corresponding hardware resources are abnormal and cannot be repaired, one or more A's may also occur. m If the device is not needed for a period of time or will not be used again afterward, the above situation requires adjustment of hardware resource allocation. However, this adjustment is only partial and will not affect unrelated A.m As one embodiment, the method further includes:
[0044] Step S10: Obtain the A to be processed m .
[0045] Among them, the A to be processed m To execute the error A m Or A that is useless within a preset time. m wait.
[0046] Step S20: Delete the pending A on the hardware. m The corresponding C j im and D j im The mapping relationship.
[0047] Step S30: Release pending A m The currently allocated hardware resources.
[0048] It should be noted that, A to be processed m Once the currently allocated hardware resources are released, they can be subsequently allocated to other A's. m .
[0049] As one embodiment, the method further includes the following after step S30:
[0050] Step S40: Obtain the instruction to add a virtual function.
[0051] Step S50: Parse the new virtual function instruction to obtain the hardware resource types required for the new virtual function and the number of hardware resources corresponding to each hardware resource type.
[0052] Step S60: Obtain the corresponding hardware resources from the unallocated hardware resources according to the type of hardware resources required for the new virtual function and the quantity of hardware resources corresponding to each type of hardware resource, and return to step S3.
[0053] It should be noted that the above steps allow for flexible allocation of hardware resources. For example, when there are still unallocated hardware resources, virtual functions can be added based on these unallocated resources. Furthermore, if the hardware resource corresponding to a virtual function malfunctions and cannot be repaired, the faulty resource A can be released. m The hardware resources, and can be repurposed for exception A. m Allocate new hardware resources. Furthermore, if a virtual function becomes unusable for a preset period, its hardware resources can be released for use by other newly added virtual functions. This process makes the hardware resources for virtual functions flexibly configurable.
[0054] Step S70: Set the logical identifier corresponding to the physical identifier of each hardware resource in the virtual function to be added according to the preset logical identifier numbering order and the hardware resource type in the virtual function to be added, and record the mapping relationship between the physical identifier and the logical identifier of each hardware resource in the virtual function to be added in the hardware.
[0055] Step S80: Load the software SW into the virtual function to be added. The software SW loaded into the virtual function to be added obtains the total number of hardware resources corresponding to each type of hardware resource.
[0056] Step S90: The software SW loaded in the virtual function to be added issues commands based on the logical identifier within the total number of hardware resources corresponding to each type of hardware resource.
[0057] Step S100: The hardware converts the logical identifier in each command into the corresponding physical identifier and executes the corresponding command.
[0058] The hardware resource allocation in this invention is completely transparent to the software, allowing the software to be reused across multiple virtual functions without the need for separate software branches. This invention establishes a mapping between the physical and logical identifiers of each hardware resource, and the logical identifiers of the same hardware resource are set in the same order across different virtual functions. Therefore, the software only needs to obtain the available quantity of each type of hardware resource in the corresponding virtual function and directly issue instructions through the logical identifiers, without needing to know the physical identifiers corresponding to the specific hardware resources. This invention enables software reusability across multiple virtual functions, reduces software complexity and communication costs, and improves the efficiency of software commands running on virtual functions.
[0059] It should be noted that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although the flowcharts describe the steps as sequential processes, many of these steps can be performed in parallel, concurrently, or simultaneously. Furthermore, the order of the steps can be rearranged. A process can be terminated when its operation is complete, but it may also have additional steps not included in the figures. A process can correspond to a method, function, procedure, subroutine, subroutine, etc.
[0060] This invention also provides an electronic device, including: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being configured to perform the method described in this invention.
[0061] This invention also provides a computer-readable storage medium storing computer-executable instructions for performing the methods described in this invention.
[0062] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention in any way. Although the present invention has been disclosed above with reference to preferred embodiments, it is not intended to limit the present invention. Any person skilled in the art can make some modifications or alterations to the above-disclosed technical content to create equivalent embodiments without departing from the scope of the present invention. Any simple modifications, equivalent changes, and alterations made to the above embodiments based on the technical essence of the present invention without departing from the scope of the present invention shall still fall within the scope of the present invention.
Claims
1. A method for operating virtual functions based on logical identifiers, characterized in that, include: Step S1: Divide the hardware resources into M virtual functions {A1, A2, ..., A...} m ,...,A M }, A m For the m-th virtual function, where m ranges from 1 to M, A m ={B1 m B2 m ,...,B i m ,...,B f(m) m }, B i m For A m The corresponding i-th type of hardware resource, where i ranges from 1 to f(m), and f(m) is A m The total number of corresponding hardware resource types; Step S2: Obtain each B i m The physical identifier {C1} corresponding to each hardware resource im C2 im ,...,C j im ,...,C g(im) m }, C j im For B i m The physical identifier of the j-th hardware resource, where j ranges from 1 to g(im), and g(im) is B. i m The total number of hardware resources in the system; Step S3: According to the preset logical identifier numbering order and each B i m The corresponding hardware resource type settings are configured for each B. i m The corresponding logical identifier {D1 im D2 im ,...,D j im ,...,D g(im) m }, D j im For B i m The physical identifier C of the j-th hardware resource j im The corresponding logical identifier, C j im and D j im The mapping relationship is recorded in the hardware; Step S4: Load the software SW into A m A was obtained from m The corresponding software in SW m ; Step S5, SW m Get each B i m The total number of corresponding hardware resources, g(im); Step S6, SW m Based on D j im Issue the order, D j im No more than D g(im) im ; Step S7: The hardware will process the corresponding D in each command. j im Convert to the corresponding C j im Execute the corresponding command.
2. The method according to claim 1, characterized in that, Step S7 includes: Step S71, Hardware based on C j im During the execution of the corresponding command, if it is necessary to allocate resources to the SW based on hardware resources... m If a command is sent or a status is replied to, then C is obtained. j im The corresponding D j i Based on D j i Generate the corresponding command or response status and send it to the SW. m .
3. The method according to claim 2, characterized in that, Step S71 includes: Step S711, Hardware based on C j im During the execution of the corresponding command, if C j im If an exception occurs, then exception C is retrieved. j im Corresponding exception D j i ; Step S712, based on exception D j i Generate an interrupt packet and send it to the switch. m .
4. The method according to claim 3, characterized in that, Following step S712, the following is also included: Steps S713 and SW m Based on anomaly D j i Generate a stop to hardware resource operation and send it to the hardware; Step S714: The hardware will stop the abnormal D in the operation of hardware resources. j i Convert to the corresponding exception C j im ; Step S715, Stop exception C j im The operation of the corresponding hardware resources.
5. The method according to claim 1, characterized in that, The method further includes: Step S10: Obtain the A to be processed m ; Step S20: Delete the pending A on the hardware. m The corresponding C j im and D j im The mapping relationship; Step S30: Release pending A m The currently allocated hardware resources.
6. The method according to claim 5, characterized in that, The A to be processed m To execute the error A m Or A that is useless within a preset time. m .
7. The method according to claim 5, characterized in that, The process following step S30 also includes: Step S40: Obtain the instruction to add a virtual function; Step S50: Parse the new virtual function instruction to obtain the hardware resource types required for the new virtual function and the number of hardware resources corresponding to each hardware resource type; Step S60: Obtain the corresponding hardware resources from the unallocated hardware resources according to the type of hardware resources required for the new virtual function and the quantity of hardware resources corresponding to each type of hardware resource. Step S70: Set the logical identifier corresponding to the physical identifier of each hardware resource in the virtual function to be added according to the preset logical identifier number order and the hardware resource type in the virtual function to be added, and record the mapping relationship between the physical identifier and the logical identifier of each hardware resource in the virtual function to be added in the hardware. Step S80: Load the software SW into the virtual function to be added. The software SW loaded into the virtual function to be added obtains the total number of hardware resources corresponding to each type of hardware resource. Step S90: The software SW loaded in the virtual function to be added issues commands based on the logical identifier within the total number of hardware resources corresponding to each type of hardware resource. Step S100: The hardware converts the logical identifier in each command into the corresponding physical identifier and executes the corresponding command.
8. The method according to claim 1, characterized in that, The hardware resources include queues, computing units, and storage space.
9. An electronic device, characterized in that, include: At least one processor; And, a memory communicatively connected to the at least one processor; The memory stores instructions that are executed by the at least one processor, the instructions being configured to perform the method of any one of claims 1-8.
10. A computer-readable storage medium, characterized in that, The device stores computer-executable instructions for performing the method of any one of claims 1-8.
Citation Information
Patent Citations
Flexible resource assignment to physical and virtual functions in a virtualized processing system
CN111176829A
Computing architecture for vehicle hardware and feature virtualization
US20220365804A1