Network card operation method and device, electronic equipment and storage medium

By introducing a driver layer, a general interface layer of command word and a hardware processing layer in the network card driver, using shared memory and message queues for communication, the problem of high dependence on the network card driver code in the existing technology is solved and scalability is improved and efficiency.

CN119003014APending Publication Date: 2024-11-22PHYTIUM TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411140001.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-19
Publication Date
2024-11-22

AI Technical Summary

Technical Problem

The hierarchical method of existing network card drivers leads to too strong dependence between codes and high coupling. When the hardware design changes, multiple code modifications may be required, resulting in poor scalability.

Method used

By deploying the driver layer, command word general interface layer and hardware processing layer on the processor, using shared memory and message queues for communication, encapsulating and parsing command words to achieve operation of network cards and reducing the coupling between the driver layer and the hardware layer. , increase scalability.

Benefits of technology

It realizes clarity of the code hierarchy, reduces the code coupling, improves scalability, facilitates support for different types of hardware, and improves program efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119003014A_ABST
    Figure CN119003014A_ABST
Patent Text Reader

Abstract

The invention provides a network card operation method and device, electronic equipment and a storage medium, and the method comprises the steps: carrying out the structural packaging of at least one command word of a target network card through a driving layer, obtaining a packaging message structural body of each command word, calling a universal interface provided by a command word universal interface layer through the driving layer, and obtaining a packaging message structural body of each command word; and writing the packaged message structural body into a message queue of a shared memory, calling a universal interface through a hardware processing layer, reading the packaged message structural body from the message queue, carrying out structured analysis on the packaged message structural body to obtain a command word, and carrying out corresponding operation on a target network card through the hardware processing layer according to the command word. According to the application, the code hierarchical structure is clear, the code coupling degree is reduced, the expandability is increased, the subsequent support of different types of hardware is facilitated, interaction between the driving layer and the hardware layer in a command word form is facilitated, communication processing is performed based on the shared memory, and the program efficiency is accelerated.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a network card operation method, device, electronic device and storage medium. Background Art

[0002] Network card drivers are divided into kernel-mode network card drivers and user-mode network card drivers. User-mode network card drivers are data plane development kit (DPDK) network drivers. DPDK network drivers are an open source data plane development kit that provides a set of C language libraries and drivers for rapid development of high-performance data plane applications.

[0003] In the related technology, the DPDK Gigabit Media Access Control (GMAC) driver is a network card packet receiving and sending solution based on the DPDK technology. The DPDK GMAC driver only includes the driver layer, which includes both software processing such as allocating receive and send queues for the network card, starting the network card, specifying the network card packet receiving and sending, specifying the number of packet receiving and sending queues, and message memory management, as well as hardware processing such as the network card rate duplex configuration, enabling the network card to send and receive, and other operations.

[0004] However, this layered approach results in strong dependencies and high coupling between codes. When the hardware design is changed, there may be multiple codes that need to be modified, resulting in poor scalability. Summary of the invention

[0005] In view of this, the embodiments of the present application provide a network card operation method, device, electronic device and storage medium to solve the problem that when the hardware design is changed, there may be multiple codes that need to be modified accordingly, resulting in poor scalability.

[0006] In a first aspect, an embodiment of the present application provides a network card operation method, which is applied to a processor connected to a target network card, wherein a driver layer, a command word general interface layer, and a hardware processing layer are deployed on the processor, and the method includes:

[0007] By means of the driver layer, at least one command word of the target network card is respectively structured and encapsulated to obtain an encapsulated message structure of each command word;

[0008] Calling the universal interface provided by the command word universal interface layer through the driver layer, writing the encapsulated message structure into the message queue of the shared memory;

[0009] Calling the universal interface through the hardware processing layer, reading the encapsulated message structure from the message queue, and performing structured analysis on the encapsulated message structure to obtain the command words;

[0010] The hardware processing layer performs corresponding operations on the target network card according to each command word.

[0011] In an optional implementation, the step of performing structured encapsulation on at least one command word of the target network card through the driver layer to obtain an encapsulated message structure of each command word includes:

[0012] Acquire the main command word and the sub-command word corresponding to each command word through the driver layer;

[0013] The driver layer performs structural encapsulation according to the main command word, the sub-command word, and the indication information item of whether the network card operation is successful, to obtain the encapsulated message structure;

[0014] The performing corresponding operations on the target network card according to the command word through the hardware processing layer includes:

[0015] The hardware processing layer performs corresponding operations on the target network card according to the main command word and the sub-command word.

[0016] In an optional embodiment, the method further comprises:

[0017] Acquire the operation result of the target network card through the hardware processing layer, the operation result being: operation success or operation failure;

[0018] The operation result is written into the indication information item through the hardware processing layer.

[0019] In an optional implementation, the network card operation is a network card configuration, and the driver layer performs structured encapsulation according to the main command word, the sub-command word, and the indication information item of whether the network card operation is successful to obtain the encapsulated message structure, including:

[0020] The driver layer performs structured encapsulation according to the main command word, the sub-command word, the indication information item of whether the network card is configured successfully, and the network card configuration parameters to obtain the encapsulated message structure;

[0021] The performing corresponding operations on the target network card according to the main command word and the sub-command word through the hardware processing layer includes:

[0022] The target network card is configured through the hardware processing layer according to the main command word, the sub-command word and the network card configuration parameters.

[0023] In an optional implementation manner, the operation result is a network card configuration result, and the method further includes:

[0024] Calling the universal interface through the driver layer to read the network card configuration result from the message queue;

[0025] If the network card configuration result is successful, the message is sent and received through the driver layer.

[0026] In an optional implementation, the network card operation is to obtain the network card configuration, and the driver layer performs structured encapsulation according to the main command word, the sub-command word, and the indication information item of whether the network card operation is successful to obtain the encapsulated message structure, including:

[0027] The driver layer performs structural encapsulation according to the main command word, the sub-command word, the indication information item of whether the network card configuration is successfully obtained, and the return value indication information item to obtain the encapsulated message structure;

[0028] The performing corresponding network card operations on the target network card according to the command word through the hardware processing layer includes:

[0029] The configuration information of the target network card is obtained through the hardware processing layer according to the main command word and the sub-command word.

[0030] In an optional embodiment, the method further comprises:

[0031] The configuration information of the target network card is written into the return value indication information item through the hardware processing layer.

[0032] In an optional implementation manner, the operation result is a network card configuration acquisition result, and the method further includes:

[0033] Calling the general interface through the driver layer to obtain the network card configuration acquisition result from the message queue;

[0034] If the network card configuration acquisition result is successful, reading the configuration information of the target network card from the message queue;

[0035] The driver layer performs software processing according to the configuration information of the target network card.

[0036] In an optional implementation, the step of writing the encapsulated message structure into a message queue of a shared memory by calling the general interface provided by the command word general interface layer through the driver layer includes:

[0037] Determine, by the driver layer, the current queue index of the message queue pointed to by the tail pointer;

[0038] Calling the general interface through the driver layer to write the encapsulated message structure into the message queue according to the current queue index;

[0039] The method further comprises:

[0040] The driver layer points the queue tail pointer to the next queue index of the message queue.

[0041] In an optional implementation, calling the general interface through the hardware processing layer to read the encapsulated message structure from the message queue includes:

[0042] Calling the general interface polling through the hardware processing layer to detect whether the queue index pointed to by the tail pointer is updated;

[0043] If it is detected that the queue index pointed to by the tail pointer is updated, the general interface is called through the hardware processing layer to read the encapsulated message structure from the message queue.

[0044] In an optional implementation, performing corresponding network card operations on the target network card according to each command word through the hardware processing layer includes:

[0045] Through the hardware processing layer, according to a first command word in the at least one command word, performing a corresponding network card operation on the target network card;

[0046] The step of writing the operation result into the indication information item through the hardware processing layer includes:

[0047] The operation result of the first command word is written into the information configuration item through the hardware processing layer.

[0048] In an optional implementation, performing corresponding network card operations on the target network card according to the command word through the hardware processing layer includes:

[0049] After calling the universal interface through the driver layer and reading the indication information of the operation result of the first command word from the message queue, the hardware processing layer performs the corresponding network card operation on the target network card according to the next command word of the first command word in the at least one command word, until the operation of the target network card is completed based on all command words.

[0050] In an optional implementation, before the driver layer performs structured encapsulation on at least one command word of the target network card to obtain an encapsulated message structure of each command word, the method further includes:

[0051] Mapping the physical address of the target network card through the driver layer to obtain the virtual address of the target network card;

[0052] Constructing a network card structure of the target network card according to the physical address of the target network card and the virtual address of the target network card through the driver layer;

[0053] The calling attribute of the network card structure is set by the driver layer, and the calling attribute is used to indicate that the network card structure is private data called by the kernel of the processor.

[0054] In an optional implementation, before sending and receiving messages through the driver layer, the method further includes:

[0055] Establishing a mapping relationship between the receiving and sending queue of the driver layer and the receiving and sending queue of the target network card through the driver layer;

[0056] The sending and receiving of messages through the driver layer includes:

[0057] Messages are sent and received through the driver layer according to the mapping relationship.

[0058] In a second aspect, an embodiment of the present application further provides a network card operation device, which is applied to a processor connected to a target network card, wherein a driver layer, a command word general interface layer, and a hardware processing layer are deployed on the processor, and the device includes:

[0059] A processing module, used for performing structured encapsulation on at least one command word of the target network card through the driver layer to obtain an encapsulated message structure of each command word;

[0060] The processing module is further used to call the universal interface provided by the command word universal interface layer through the driver layer to write the encapsulated message structure into the message queue of the shared memory;

[0061] An acquisition module, used for calling the universal interface through the hardware processing layer, reading the encapsulated message structure from the message queue, and performing structured analysis on the encapsulated message structure to obtain the command words;

[0062] The processing module is further used to perform corresponding operations on the target network card according to the command words through the hardware processing layer.

[0063] In an optional implementation manner, the processing module is specifically used to:

[0064] Acquire the main command word and the sub-command word corresponding to each command word through the driver layer;

[0065] The driver layer performs structural encapsulation according to the main command word, the sub-command word, and the indication information item of whether the network card operation is successful, to obtain the encapsulated message structure;

[0066] The processing module is specifically used for:

[0067] The hardware processing layer performs corresponding operations on the target network card according to the main command word and the sub-command word.

[0068] In an optional implementation manner, the acquisition module is further used to:

[0069] Acquire the operation result of the target network card through the hardware processing layer, the operation result being: operation success or operation failure;

[0070] The processing module is further used to write the operation result into the indication information item through the hardware processing layer.

[0071] In an optional implementation manner, the network card operation is a network card configuration, and the processing module is further used to:

[0072] The driver layer performs structured encapsulation according to the main command word, the sub-command word, the indication information item of whether the network card is configured successfully, and the network card configuration parameters to obtain the encapsulated message structure;

[0073] The processing module is specifically used to configure the target network card according to the main command word, the sub-command word and the network card configuration parameters through the hardware processing layer.

[0074] In an optional implementation manner, the operation result is a network card configuration result, and the acquisition module is further used to:

[0075] Calling the universal interface through the driver layer to read the network card configuration result from the message queue;

[0076] The transceiver module is used to send and receive messages through the driver layer if the network card configuration result is successful.

[0077] In an optional implementation manner, the network card operation is to obtain a network card configuration, and the processing module is specifically configured to:

[0078] The driver layer performs structural encapsulation according to the main command word, the sub-command word, the indication information item of whether the network card configuration is successfully obtained, and the return value indication information item to obtain the encapsulated message structure;

[0079] The processing module is specifically used to obtain the configuration information of the target network card according to the main command word and the sub-command word through the hardware processing layer.

[0080] In an optional implementation, the processing module is further used to:

[0081] The configuration information of the target network card is written into the return value indication information item through the hardware processing layer.

[0082] In an optional implementation manner, the operation result is a network card configuration acquisition result, and the acquisition module is further used to:

[0083] Calling the general interface through the driver layer to obtain the network card configuration acquisition result from the message queue;

[0084] If the network card configuration acquisition result is successful, reading the configuration information of the target network card from the message queue;

[0085] The processing module is further used for:

[0086] The driver layer performs software processing according to the configuration information of the target network card.

[0087] In an optional implementation manner, the processing module is specifically used to:

[0088] Determine, by the driver layer, the current queue index of the message queue pointed to by the tail pointer;

[0089] Calling the general interface through the driver layer to write the encapsulated message structure into the message queue according to the current queue index;

[0090] The processing module is further used for:

[0091] The driver layer points the queue tail pointer to the next queue index of the message queue.

[0092] In an optional implementation manner, the acquisition module is specifically used to:

[0093] Calling the general interface polling through the hardware processing layer to detect whether the queue index pointed to by the tail pointer is updated;

[0094] If it is detected that the queue index pointed to by the tail pointer is updated, the general interface is called through the hardware processing layer to read the encapsulated message structure from the message queue.

[0095] In an optional implementation manner, the processing module is specifically used to:

[0096] Through the hardware processing layer, according to a first command word in the at least one command word, performing a corresponding network card operation on the target network card;

[0097] The step of writing the operation result into the indication information item through the hardware processing layer includes:

[0098] The operation result of the first command word is written into the information configuration item through the hardware processing layer.

[0099] In an optional implementation manner, the processing module is specifically used to:

[0100] After calling the universal interface through the driver layer and reading the indication information of the operation result of the first command word from the message queue, the hardware processing layer performs the corresponding network card operation on the target network card according to the next command word of the first command word in the at least one command word, until the operation of the target network card is completed based on all command words.

[0101] In a third aspect, an embodiment of the present application further provides an electronic device, comprising: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor communicates with the memory through the bus, and the processor executes the machine-readable instructions to execute any one of the methods described in the first aspect.

[0102] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the method described in any one of the first aspects is executed.

[0103] The present application provides a network card operation method, device, electronic device and storage medium, wherein the method comprises: structurally encapsulating at least one command word of the target network card through the driver layer, obtaining the encapsulated message structure of each command word, calling the general interface provided by the command word general interface layer through the driver layer, writing the encapsulated message structure into the message queue of the shared memory, calling the general interface through the hardware processing layer, reading the encapsulated message structure from the message queue, and structurally parsing the encapsulated message structure to obtain the command word, and performing corresponding operations on the target network card according to the command word through the hardware processing layer. The code hierarchy of the present application is clear, which reduces the code coupling degree, increases the scalability, and facilitates the subsequent support of different types of hardware. The driver layer and the hardware layer interact in the form of command words, and perform communication processing based on shared memory to speed up the program efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0104] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0105] Figure 1 This is a schematic diagram of the kernel-mode network card driver;

[0106] Figure 2 This is a schematic diagram of the user-mode network card driver;

[0107] Figure 3 This is the architecture diagram of the DPDK GMAC driver;

[0108] Figure 4 A hardware structure diagram of the Ethernet interface circuit provided in the embodiment of the present application;

[0109] Figure 5 Schematic diagram of the process of the network card operation method provided in the embodiment of the present application Figure 1 ;

[0110] Figure 6 A reconstructed architecture diagram of the DPDK GMAC network driver provided in an embodiment of the present application;

[0111] Figure 7 Schematic diagram of the process of the network card operation method provided in the embodiment of the present application Figure 2 ;

[0112] Figure 8 Schematic diagram of the process of the network card operation method provided in the embodiment of the present application Figure 3 ;

[0113] Fig. 9 A schematic diagram of a shared memory and a message queue provided in an embodiment of the present application;

[0114] Fig.10 Schematic diagram of the process of the network card operation method provided in the embodiment of the present application Figure 4 ;

[0115] Fig.11 Schematic diagram of the process of the network card operation method provided in the embodiment of the present application Figure 5 ;

[0116] Fig.12 Schematic diagram of the process of the network card operation method provided in the embodiment of the present application Figure 6 ;

[0117] Fig.13 A flowchart of a specific network card configuration method provided in an embodiment of the present application;

[0118] Fig.14 A schematic diagram of the structure of a network card operating device provided in an embodiment of the present application;

[0119] Fig.15 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0120] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. The components of the embodiments of the present application generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.

[0121] Network card drivers are divided into kernel-mode network card drivers and user-mode network card drivers. Figure 1 This is a schematic diagram of the kernel-mode network card driver. Figure 2 The figure is a schematic diagram of the user-mode network card driver. The kernel-mode network card driver is a module in the Linux kernel that manages data transmission between the computer and the network. It provides a set of interfaces and functions that allow the operating system to communicate with the network card (network controller) and control the sending and receiving of data. The user-mode network card driver is a network driver of the Data Plane Development Kit (DPDK). DPDK is an open source data plane development toolkit that provides a set of C language libraries and drivers for rapid development of high-performance data plane applications. DPDK uses user-mode input / output (UIO) technology to implement network packet processing in user space. UIO technology allows applications to bypass the kernel and directly operate the memory space of the network card through the user space driver, avoiding the data memory copy between the kernel space and the user space, and improving data processing efficiency.

[0122] The DPDK Gigabit Media Access Control (GMAC) driver manages the network card hardware and sends and receives messages through the GMAC user mode driver and UIO driver. Figure 3 This is the architecture diagram of the DPDK GMAC driver, such as Figure 3As shown, the GMAC user-mode driver includes a user-mode physical layer (Physical, PHY) interface driver and a user-mode media access control (MAC) driver. The GMAC user-mode driver corresponds to the driver layer and belongs to the user space.

[0123] UIO is a technical solution for user-mode access to hardware devices based on the kernel UIO mechanism. Generally, hardware device drivers in Linux systems run in kernel mode, and applications in user mode indirectly access hardware devices by calling kernel interfaces. However, UIO technology leaves a small part of the device driver running in kernel mode, and implements more device functions in user-mode applications. UIO belongs to kernel space.

[0124] The network card corresponds to the physical layer, and the network card includes internal MAC and external PHY.

[0125] Among them, the DPDK GMAC driver is a network card packet receiving and sending solution based on DPDK technology. The DPDK GMAC driver receives packets from the physical layer network card and copies the data packets from the network card to the packet receiving queue through direct memory access (DMA) operation. The DPDK GMAC driver takes packets from the packet receiving queue and forwards the packets. At the same time, the driver can use DMA operation to copy the packets in the network card queue to the network card, and finally the network card completes the packet sending.

[0126] It is worth noting that the forwarding operation here refers to the DPDK GMAC driver receiving packets from port 1 of the network card device and forwarding the packets to port 2 of the network card device for sending. The corresponding software processing flow is: the DPDK GMAC driver copies the message in the hardware queue of the physical layer network card port 1 to the packet receiving queue of the driver port 1, and then copies the message in the packet receiving queue of the driver port 1 to the packet sending queue of the driver port 2, and copies the message in the packet sending queue of the driver port 2 to the hardware queue of the network card port 2, and finally completes the packet sending and receiving.

[0127] It can be seen that the DPDK GMAC driver only includes the driver layer, which includes software processing such as allocating receive and send queues for the network card, starting the network card, specifying the network card to send and receive packets, specifying the number of send and receive packet queues, and message memory management, as well as hardware processing such as the network card rate duplex configuration, enabling the network card to send and receive, and other operations.

[0128] Among them, the receiving queue allocated to the network card is used to store the messages received by the network card, and the sending queue allocated to the network card is used to store the messages sent to the network card. Specifying the network card to send and receive packets can be understood as the user needs to specify the network card device when using the DPDK GMAC driver, and the driver processes the sending and receiving packets according to the specified network card device. Specifying the number of sending and receiving queues can be understood as the number of software sending and receiving queues set by the user when using the DPDK GMAC driver. For example, when the sending queue is set to 1, it means that only one sending queue can send messages. Memory management can be understood as applying for memory and releasing memory for the sending queue and receiving queue at the driver level. Message management can be understood as judging the message type and length in the memory.

[0129] However, the layered approach of the DPDK GMAC driver results in strong dependencies and high coupling between codes. When the hardware design is changed, there may be multiple codes that need to be modified accordingly, resulting in poor scalability.

[0130] For example, before the hardware design is modified, the MAC reset transmit (transport, TX) queue of the network card needs to configure bit 1 of register A to 0. After the hardware design is modified, the MAC reset TX queue needs to configure bit 2 of register A to 0. Therefore, all processes related to MAC reset TX queue in the GMAC driver (initialization process, reset process, exit process) need to modify bit 1 of register A to bit 2, and 3 places need to be modified.

[0131] Based on this, the present application provides a network card operation method, which can reduce the dependency between DPDK GMAC driver codes, reduce the coupling degree, and improve the scalability, so as to facilitate the subsequent support of different types of hardware.

[0132] For example, before the hardware design is modified, the MAC resets the TX queue and needs to configure bit 1 of register A to 0. After the hardware design is modified, the MAC resets the TX queue and needs to configure bit 2 of register A to 0. In this case, the GMAC driver only needs to modify bit 1 of register A to bit 2 in the specific implementation interface of the command word (PHYTMAC_MSG_CMD_DEFAULT_RESET_TX_QUEUE) corresponding to the MAC reset TX queue of the hardware processing layer. Only this one place needs to be modified.

[0133] Figure 4 The hardware structure diagram of the Ethernet interface circuit provided in the embodiment of the present application is as follows: Figure 4The Ethernet interface circuit (network card) shown in the figure is mainly composed of two parts: MAC controller and PHY interface. DMA controller is part of CPU / MCU. The dashed arrow connecting MAC and DMA controller indicates that DMA controller will participate in network port data transmission. CPU / MCU also includes core.

[0134] It is worth noting that the MAC controller corresponds to the data link layer. The MAC controller handles the assembly of data frames, addressing, error detection (but not correction, which is the responsibility of the upper layer protocol), frame transmission and reception, etc. The PHY interface corresponds to the physical layer and is responsible for transmitting the original bit stream through the physical medium. Functions include data encoding and decoding, voltage conversion, driver and receiver management, data transmission rate adaptation, and physical connection maintenance.

[0135] Figure 5 Schematic diagram of the process of the network card operation method provided in the embodiment of the present application Figure 1 The execution subject of this embodiment may be a processor connected to the target network card, such as a CPU or an MCU. A driver layer, a command word general interface layer, and a hardware processing layer are deployed on the processor.

[0136] Figure 6 The reconstructed architecture diagram of the DPDK GMAC network driver provided in the embodiment of the present application is as follows: Figure 6 As shown, the DPDKGMAC driver is divided into three layers, namely the driver layer, the command word general interface layer and the hardware processing layer.

[0137] Among them, the driver layer includes user-state PHY driver, user-state MAC driver and command word issuing unit. The user-state PHY driver is used to manage PHY, including PHY initialization, reset, sleep and wake-up functions. The user-state MAC driver is used to allocate receiving and sending queues for the network card, start the network card, specify the network card to send and receive packets, specify the number of sending and receiving packet queues, and message memory management functions.

[0138] The command word general interface layer is a bridge for information transmission between the driver layer and the hardware processing layer. It completes the shared memory mapping, initializes the message structure of the command word interaction, and provides the command word processing interface. When the driver layer needs to initialize, reset, enable, and other configurations of the network card, the command word issuing unit in the driver layer first encapsulates the command word interaction message structure, and then calls the unified interface provided by the command word general interface layer. The unified interface uses shared memory to pass information to the hardware processing layer. The hardware processing layer obtains information from the shared memory and parses it, thereby completing the hardware configuration corresponding to the command word.

[0139] like Figure 5 As shown, the method may include:

[0140] S101. Perform structured encapsulation on at least one command word of a target network card through a driver layer to obtain an encapsulated message structure of each command word.

[0141] The target network card command word is used to perform corresponding operations on the target network card. The target network card command word can be, for example, a network card configuration command word or a command word for obtaining network card configuration. The network card configuration command word is used to configure the target network card, and the command word for obtaining network card configuration is used to obtain configuration information of the target network card.

[0142] When performing a network card operation on a target network card, at least one command word of the target network card may be obtained through the driver layer, and the at least one command word may be structured and encapsulated to obtain an encapsulated message structure of each command word.

[0143] S102: Calling the general interface provided by the command word general interface layer through the driver layer to write the encapsulated message structure into the message queue of the shared memory.

[0144] The driver layer calls the general interface provided by the command word general interface layer to write the encapsulated message structure of each command word into the message queue of the shared memory.

[0145] Among them, the interaction between the driver layer and the hardware processing layer is mainly completed based on shared memory. In an optional implementation, the physical space of the shared memory is divided into multiple controls of fixed size to form a TX queue, and the TX queue is managed by means of a ring buffer. Each queue element in the TX queue corresponds to an encapsulated message result body.

[0146] S103 , calling the general interface through the hardware processing layer, reading the encapsulated message structure from the message queue, and performing structured analysis on the encapsulated message structure to obtain various command words.

[0147] S104. Perform corresponding operations on the target network card according to each command word through the hardware processing layer.

[0148] The general interface provided by the command word general interface layer is called through the hardware processing layer, the encapsulated message structure is read from the message queue, and the encapsulated message structure is structurally parsed to obtain each command word.

[0149] The hardware processing layer performs corresponding operations on the target network card according to each command word. If the command word is a network card configuration command word, the hardware processing layer performs corresponding configuration on the target network card, for example, resetting the network card, initializing the network card, configuring the MAC address, etc.

[0150] If the command word is a command word for obtaining the configuration of the network card, the configuration information of the target network card is obtained through the hardware processing layer, for example, obtaining the functions supported by the network card, obtaining the statistical counting status of the network card, obtaining the receive (RX) flow control of the network card, etc.

[0151] In an optional implementation, performing corresponding network card operations on the target network card according to each command word through the hardware processing layer includes: performing corresponding network card operations on the target network card according to a first command word in at least one command word through the hardware processing layer;

[0152] Writing the operation result into the indication information item through the hardware processing layer includes: writing the operation result of the first command word into the information configuration item through the hardware processing layer.

[0153] In an optional implementation, the hardware processing layer performs corresponding network card operations on the target network card according to the command word, including:

[0154] After calling the general interface through the driver layer and reading the indication information of the operation result of the first command word from the message queue, the hardware processing layer performs the corresponding network card operation on the target network card according to the next command word of the first command word in at least one command word, until the operation of the target network card is completed based on all command words.

[0155] If the network card hardware configuration requires sequential execution, the driver layer must wait for the target network card to complete processing after encapsulating a single command word and sending it to the hardware processing layer through the general interface layer. That is, after the hardware processing layer performs corresponding operations on the target network card according to the command word, and obtains the operation result of the first configuration command word, the operation result of the first configuration command word is written into the indication information item.

[0156] After calling the general interface through the driver layer and reading the indication information of the operation result of the first command word from the message queue, the hardware processing layer performs the corresponding network card operation on the target network card according to the next command word of the first command word in at least one command word, and repeats this process until the operation of the target network card is completed based on all command words.

[0157] In another optional implementation, if the network card hardware configuration does not require sequential execution, at least one command word is structured and encapsulated separately through the driver layer to obtain an encapsulated message structure of each command word, and the encapsulated message structure of each command word is simultaneously sent to the hardware processing layer through the command word universal interface, and the hardware processing layer performs network card operations on the target network card according to each command word.

[0158] In this embodiment, the original driver layer of the DPDK GMAC driver is divided into three layers, including a driver layer, a command word general interface layer, and a hardware processing layer. The divided driver layer retains the software processing functions of the user-mode PHY driver and the user-mode MAC driver, such as allocating receiving and sending queues for the network card, starting the network card, specifying the network card to send and receive packets, specifying the number of sending and receiving packet queues, and message memory management functions. The driver layer operates the network card by calling the command word general interface by issuing command words. The general interface layer uses shared memory to pass information such as command word parameters to the lower layer. The hardware processing layer obtains information from the shared memory and parses out information such as command words and parameters to complete the network card configuration operation corresponding to the command word. By layering the driver layer, the code coupling is reduced and the scalability is increased, which is convenient for subsequent support of different types of hardware. The driver layer and the hardware layer interact in the form of command words, and communication processing is performed based on shared memory to speed up program efficiency.

[0159] Figure 7 Schematic diagram of the process of the network card operation method provided in the embodiment of the present application Figure 2 ,like Figure 7 As shown, in an optional implementation, the above step S101, through the driver layer, structurally encapsulates at least one command word of the target network card to obtain an encapsulated message structure of each command word, including:

[0160] S201. Obtain a main command word and a sub-command word corresponding to each command word through a driver layer.

[0161] The main command word corresponding to the command word is used to indicate the operation type of the command word, and the sub-command word corresponding to the command word is used to indicate the operation description under the operation type.

[0162] For example, the main command word corresponding to the command word of the target network card is PHYTMAC_MSG_CMD_SE (dispatching configuration), and the sub-command word corresponding to the command word of the target network card is PHYTMAC_MSG_CMD_SET_INIT_ALL (network card hardware initialization).

[0163] For another example, the sub-command word corresponding to the command word for the target network card is PHYTMAC_MSG_CMD_GET (get configuration), and the sub-command word corresponding to the command word for the target network card is PHYTMAC_MSG_CMD_GET_ADDR (get MAC address).

[0164] S202: The driver layer performs structured encapsulation according to the main command word, the sub-command word, and the information item indicating whether the network card operation is successful, to obtain an encapsulated message structure.

[0165] The driver layer performs structured encapsulation of each command word according to the main command word, sub-command word, and indication information item of whether the network card operation is successful to obtain an encapsulated message structure, which includes: the main command word, sub-command word, and indication information item of whether the network card operation is successful.

[0166] Taking the main command word as an example, the main command word can be expressed as msg_info.cmd_id: PHYTMAC_MSG_CMD_SET, the sub-command word can be expressed as msg_info.cmd_subid=PHYTMAC_MSG_CMD_SET_INIT_ALL, and the information item indicating whether the network card operation is successful can be expressed as Flags, where if the network card operation is successful, Flags=1, and if the network card operation fails, Flags=0.

[0167] The above step S104, performing corresponding operations on the target network card according to the command word through the hardware processing layer, may include:

[0168] S203: Perform corresponding operations on the target network card according to the main command word and the sub-command word through the hardware processing layer.

[0169] The hardware processing layer configures the target network card accordingly or obtains the configuration information of the target network card according to the main command word and the sub-command word.

[0170] In an optional embodiment, the method may further include:

[0171] S204: Obtain the operation result of the target network card through the hardware processing layer.

[0172] After performing corresponding operations on the target network card, the operation result of the target network card is obtained through the hardware processing layer, and the operation result is: operation success or operation failure.

[0173] S205. Write the operation result into the indication information item through the hardware processing layer.

[0174] The operation result is written into the indication information item through the hardware processing layer. If the operation result is successful, the value of the indication information item may be 1, that is, Flags=1. If the operation result is failed, the value of the indication information item may be 0, that is, Flags=0.

[0175] Figure 8 Schematic diagram of the process of the network card operation method provided in the embodiment of the present application Figure 3 ,like Figure 8As shown, in an optional implementation, the network card operation is the network card configuration, and the above step S202, through the driver layer, performs structured encapsulation according to the main command word, the sub-command word, and the indication information item of whether the network card operation is successful, to obtain an encapsulated message structure, which may include:

[0176] S301. The driver layer performs structured encapsulation according to the main command word, the sub-command word, the indication information item of whether the network card is configured successfully, and the network card configuration parameters to obtain an encapsulated message structure.

[0177] If the network card operation is network card configuration, the command word is a network card configuration command word, and the driver layer performs structural encapsulation according to the main command word, the sub-command word, the information item indicating whether the network card is configured successfully, and the network card configuration parameters to obtain an encapsulated message structure. The encapsulated message structure includes: the main command word (msg_info.cmd_id), the sub-command word (msg_info.cmd_subid), the information item indicating whether the network card is configured successfully (Flags), and the network card configuration parameters (para).

[0178] As an example:

[0179]

[0180]

[0181] Example of encapsulated message structure:

[0182] phytmac_msg_info_t msg_info;

[0183] msg_info.cmd_id=PHYTMAC_MSG_CMD_SET;

[0184] msg_info.cmd_subid=PHYTMAC_MSG_CMD_SET_INIT_ALL;

[0185] msg_info.para[0]=PHYTMAC_PHY_INTERFACE_MODE_SGMII.

[0186] Among them, PHYTMAC_MSG_CMD_SET indicates configuration sending, PHYTMAC_MSG_CMD_SET_INIT_ALL indicates hardware initialization, and PHYTMAC_PHY_INTERFACE_MODE_SGMII indicates the number of network card send and receive queues.

[0187] Taking the main command word PHYTMAC_MSG_CMD_DEFAULT (reset) as an example, the sub-command word PHYTMAC_MSG_CMD_DEFAULT_RESET_TX_QUEUE means resetting the network card TX queue, the sub-command word PHYTMAC_MSG_CMD_DEFAULT_RESET_TX_QUEUE means resetting the network card TX queue, and the sub-command word PHYTMAC_MSG_CMD_DEFAULT_RESET_RX_QUEUE means resetting the network card RX queue.

[0188] Taking the main command word PHYTMAC_MSG_CMD_SE (dispatching configuration) as an example, the sub-command word PHYTMAC_MSG_CMD_SET_INIT_ALL indicates the initialization of the network card hardware, and the sub-command word PHYTMAC_MSG_CMD_SET_INIT_RING indicates the initialization of the network card TX and RX.

[0189] The network card configuration parameter may be the number of network card receiving and / or sending queues.

[0190] In the above step S203, the hardware processing layer performs corresponding operations on the target network card according to the main command word and the sub-command word, including:

[0191] S302: Configure the target network card through the hardware processing layer according to the main command word, the sub-command word and the network card configuration parameters.

[0192] After the target network card is configured according to the main command word, sub-command word and network card configuration parameters through the hardware processing layer, the network card configuration result can be obtained, and the network card configuration result can be written into the indication information item through the hardware processing layer. If the network card configuration result is a successful configuration, the value of the indication information item can be 1, that is, Flags=1; if the network card configuration result is a failed configuration, the value of the indication information item can be 0, that is, Flags=0.

[0193] In an optional implementation, the operation result is a network card configuration result, and the method may further include:

[0194] S303, calling the general interface through the driver layer to read the network card configuration result from the message queue.

[0195] S304: If the network card configuration result is successful, the driver layer sends and receives messages.

[0196] If the network card operation is network card configuration, the operation result is the network card configuration result. The driver layer calls the general interface provided by the command word general interface layer to read the network card configuration result from the message queue. If the network card configuration result is a successful configuration, it means that the target network card is configured successfully, and the target network card can be used to send and receive messages through the driver layer.

[0197] That is to say, if the network card configuration is successful, the software layer will continue to execute downwards; if the network card configuration fails, the software layer will no longer execute downwards and can also exit the program after recycling resources.

[0198] Take the network card configuration as an example. Fig. 9 A schematic diagram of a shared memory and a message queue provided in an embodiment of the present application, such as Fig. 9 As shown, each queue element in the message queue corresponds to an encapsulated message structure, which includes: a main command word (msg_info.cmd_id), a sub-command word (msg_info.cmd_subid), an indication information item (Flags) indicating whether the network card configuration is successful, and a network card configuration parameter (para).

[0199] In the first step, the driver layer triggers a write request and writes the encapsulated message structure into the message queue of the shared memory. In the second step, the hardware processing layer reads the encapsulated message result body from the message queue and configures the target network card. In the third step, the network card configuration result is written into the indication information item. In the fourth step, the driver layer reads the network card configuration result from the message queue.

[0200] Depend on Fig. 9 It can be seen that the driver layer and the hardware processing layer perform communication processing based on shared memory, and a ring queue is implemented in shared memory management.

[0201] In an optional implementation, in the above step S304, before the driver layer sends and receives messages, the method may further include:

[0202] A mapping relationship between the receiving and sending queues of the driver layer and the receiving and sending queues of the target network card is established through the driver layer.

[0203] The receiving and sending queue of the driver layer includes a packet receiving queue of the driver layer and a packet sending queue of the driver layer, and the receiving and sending queue of the target network card includes a packet receiving queue of the target network card and a packet sending queue of the target network card.

[0204] Establishing a mapping relationship between the transceiver queue of the driver layer and the transceiver queue of the target network card through the driver layer can be understood as initializing the transceiver queue of the target network card. In an optional implementation, the physical address corresponding to the transceiver queue of the driver layer is configured into the transceiver queue register of the target network card to implement initialization processing of the target network card.

[0205] Among them, the initialization command word of the transceiver queue of the target network card can be expressed as PHYTMAC_MSG_CMD_SET_INIT_RING. The initialization command word of the target network card is structurally encapsulated through the driver layer to obtain the encapsulated message structure of the initialization command word, and the driver layer calls the general interface provided by the command word general interface layer to write the encapsulated message structure into the message queue of the shared memory, and the hardware processing layer calls the general interface to read the encapsulated message structure from the message queue, and the encapsulated message structure is structurally parsed to obtain the initialization command word, and the hardware processing layer initializes the transceiver queue of the target network card according to each command word.

[0206] In the above step S304, sending and receiving messages through the driver layer may include:

[0207] Messages are sent and received through the driver layer according to the mapping relationship.

[0208] During the data packet receiving process, the received data packet is stored in the packet receiving queue of the target network card, and is copied from the packet receiving queue of the target network card to the packet receiving queue of the driver layer through DMA operation. During the data packet sending process, the data to be sent is stored in the packet sending queue of the driver layer, and is copied from the packet sending queue of the driver layer to the packet sending queue of the target network card through DMA operation.

[0209] In this embodiment, the driver layer performs hardware configuration of the network card by calling the command word general interface by issuing command words. The general interface layer uses shared memory to pass command word parameters and other information to the lower layer. The hardware processing layer obtains information from the shared memory and parses the command word, parameters and other information to complete the network card configuration corresponding to the command word.

[0210] Fig.10 Schematic diagram of the process of the network card operation method provided in the embodiment of the present application Figure 4 ,like Fig.10 As shown, in an optional implementation, the network card operation is to obtain the network card configuration, and the above step S202, through the driver layer, performs structured encapsulation according to the main command word, the sub-command word, and the indication information item of whether the network card operation is successful, to obtain an encapsulated message structure, which may include:

[0211] S401. The driver layer performs structural encapsulation according to the main command word, the sub-command word, the indication information item of whether the network card configuration is successfully obtained, and the return value indication information item to obtain an encapsulated message structure.

[0212] If the network card operation is to obtain the network card configuration, the command word is the command word for obtaining the network card configuration, and the driver layer performs structural encapsulation according to the main command word, the sub-command word, the information item indicating whether the network card configuration is successfully obtained, and the return value indication information item to obtain the encapsulated message structure. The encapsulated message structure includes: (msg_info.cmd_id), the sub-command word (msg_info.cmd_subid), the information item indicating whether the network card configuration is successfully obtained (Flags), and the return value indication information item (para).

[0213] For example, the main command word includes PHYTMAC_MSG_CMD_GET (get configuration), and the main command word includes multiple sub-command words, such as PHYTMAC_MSG_CMD_GET_ADDR, which means getting a MAC address.

[0214] In the above step S203, the hardware processing layer performs corresponding operations on the target network card according to the main command word and the sub-command word, including:

[0215] S402: Obtain configuration information of the target network card through the hardware processing layer according to the main command word and the sub-command word.

[0216] The configuration information of the target network card is obtained according to the main command word and the sub-command word through the hardware processing layer, and the network card configuration acquisition result can be obtained, and the network card configuration acquisition result is written into the indication information item through the hardware processing layer. If the network card configuration acquisition result is successful acquisition, the value of the indication information item can be 1, that is, Flags=1; if the network card configuration acquisition result is failed acquisition, the value of the indication information item can be 0, that is, Flags=0.

[0217] In an optional embodiment, the method may further include:

[0218] S403: Write the configuration information of the target network card into the return value indication information item through the hardware processing layer.

[0219] The hardware processing layer obtains the configuration information of the target network card according to the main command word and the sub-command word, and writes the configuration information of the target network card into the return value indication information item, that is, the configuration information of the target network card is used as the value of the return value indication information item.

[0220] Taking the subcommand word PHYTMAC_MSG_CMD_GET_ADDR (get MAC address) of PHYTMAC_MSG_CMD_GET (get configuration) as an example, after the MAC address of the target network card is obtained through the hardware processing layer, the MAC address of the target network card is used as the value of the return value indication information item.

[0221] In an optional implementation, the operation result is a network card configuration acquisition result, and the method may further include:

[0222] S404: Call the general interface through the driver layer to obtain the network card configuration acquisition result from the message queue.

[0223] S405: If the network card configuration acquisition result is successful, the configuration information of the target network card is acquired from the message queue.

[0224] S406: Perform software processing according to the configuration information of the target network card through the driver layer.

[0225] The driver layer calls the general interface provided by the command word general interface to obtain the network card configuration acquisition result from the message queue. If the network card configuration acquisition result is successful, the configuration information of the target network card is obtained from the message queue, and software processing is performed according to the configuration information of the target network card.

[0226] The software processing includes but is not limited to saving the number of network card queues at the software level and saving the data packets received by the target network card into the software queue.

[0227] In this embodiment, the driver layer obtains the network card configuration by calling the command word general interface by issuing command words. The general interface layer uses shared memory to pass command word parameters and other information to the lower layer. The hardware processing layer obtains information from the shared memory and parses the command word, parameters and other information to complete the acquisition of the network card configuration corresponding to the command word.

[0228] Fig.11 Schematic diagram of the process of the network card operation method provided in the embodiment of the present application Figure 5 ,like Fig.11 As shown, in an optional implementation, the above step S102, calling the general interface provided by the command word general interface layer through the driver layer to write the encapsulated message structure into the message queue of the shared memory, includes:

[0229] S501. Determine, through the driver layer, the current queue index of the message queue pointed to by the tail pointer.

[0230] The tail pointer (tx_tail) is used to point to the queue index of the message queue where the new element is to be inserted, and the current queue index of the message queue pointed to by the tail pointer is determined to be the queue index of the message queue where the new element is to be inserted.

[0231] S502: Calling a general interface through the driver layer to write the encapsulated message structure into the message queue according to the current queue index.

[0232] The driver layer calls the general interface provided by the command word general interface layer, and writes the encapsulated message structure into the current queue index of the message queue as a new element to be inserted according to the current queue index.

[0233] The method may further include:

[0234] S503: Point the queue tail pointer to the next queue index of the message queue through the driver layer.

[0235] After the encapsulated message structure is written into the current queue index of the message queue, if the queue index of the new element to be inserted into the message queue changes, the driver layer will point the tail pointer to the next queue index of the current queue index of the message queue, where the queue index of the new element to be inserted is updated to the next queue index, that is, the tail pointer is ++ed to point the tail pointer to the next element of the message queue.

[0236] In an optional implementation, the above step S103, calling the general interface through the hardware processing layer to read the encapsulated message structure from the message queue, may include:

[0237] S504: Call the general interface through the hardware processing layer to poll and detect whether the queue index pointed to by the tail pointer is updated.

[0238] S505: If it is detected that the queue index pointed to by the tail pointer is updated, the general interface is called through the hardware processing layer to read the encapsulated message structure from the message queue.

[0239] The general interface is called through the hardware processing layer to poll and detect whether the queue index pointed to by the tail pointer is updated. If it is detected that the queue index pointed to by the tail pointer is updated, that is, tx_tail increases, it means that the encapsulated message structure is written to the message queue. Then, the general interface is called through the hardware processing layer to read the encapsulated message structure from the message queue.

[0240] In this embodiment, the original driver layer of the DPDK GMAC driver is divided into three layers, including a driver layer, a command word general interface layer, and a hardware processing layer. The driver layer and the hardware processing layer use a shared memory message queue to transmit command words through a tail pointer, so as to perform communication processing based on shared memory and speed up program efficiency.

[0241] Fig.12 Schematic diagram of the process of the network card operation method provided in the embodiment of the present application Figure 6 ,like Fig.12 As shown, in an optional implementation, in the above step S101, before the driver layer performs structured encapsulation on at least one command word of the target network card to obtain the encapsulated message structure of each command word, the method may further include:

[0242] S601. Map the physical address of the target network card through the driver layer to obtain the virtual address of the target network card.

[0243] The physical address of the target network card is obtained through the driver layer, and the physical address of the target network card is mapped to obtain the virtual address of the target network card.

[0244] In an optional implementation, the memory resources of the target network card are acquired through the driver layer, and the physical address of the target network card is calculated according to the memory resources of the target network card.

[0245] S602: Construct a network card structure of the target network card according to the physical address of the target network card and the virtual address of the target network card through the driver layer.

[0246] A preset network card structure is allocated to the target network card, the physical address of the target network card and the virtual address of the target network card are saved in the preset network card structure, and the network card structure of the target network card is constructed.

[0247] S603: Set the calling properties of the network card structure through the driver layer.

[0248] Among them, the call attribute is used to indicate that the network card structure is private data called by the processor kernel. The network card structure is set as private data called by the processor kernel through the driver layer, so that the corresponding operation can be performed on the target network card through the hardware processing layer deployed on the processor.

[0249] As an example, the target network card is bound through the dpdk-pdevbind.sh script. Binding the target network card will call the probe function in the uio driver. The process of the probe function is as follows: assign a preset network card structure rte_uio_platform_dev to the target network card, then call platform_get_resource to obtain the physical address of the target network card and map it, save the physical address and the mapped virtual address to the preset network card structure, and obtain the network card structure of the target network card.

[0250] In this embodiment, the network card result body of the target network card is called by the driver layer, so that the subsequent driver layer and the hardware layer can interact in the form of command words, and communication processing is performed based on shared memory to perform corresponding operations on the target network card, thereby speeding up program efficiency.

[0251] Take the network card configuration as an example. Fig.13 A flowchart of a specific network card configuration method provided in an embodiment of the present application is shown as follows: Fig.13 As shown, the driver layer performs the following steps:

[0252] 1. Find and add the target network card.

[0253] For the specific method of searching and adding the target network card, please refer to the implementation process of setting the calling properties of the network card structure by setting the driver layer.

[0254] 2. Obtain the memory resources of the target network card and remap the physical address.

[0255] The remapping of the physical address is to calculate the physical address of the target network card according to the memory resources of the target network card.

[0256] The command word general interface layer execution steps are as follows:

[0257] 1. Initialize the encapsulated message structure.

[0258] 2. Provide a general interface for command word processing.

[0259] Next, the driver layer performs the following steps:

[0260] 1. Initialize the send and receive queues of the target network card.

[0261] 2. Encapsulate the command word to obtain the encapsulated message structure, and send the encapsulated message structure.

[0262] 3. Call the general interface and put the encapsulated message structure into the message queue of the shared memory.

[0263] 4. Set the tail pointer to the next queue index of the message queue.

[0264] The hardware processing layer performs the following steps:

[0265] 1. Poll and detect the update of the queue index pointed to by the tail pointer, obtain the encapsulated message structure from the message queue, and parse and execute the corresponding network card configuration.

[0266] 2. If the configuration is successful, the indication information item in the message queue is set to 1; if the configuration fails, the indication information item in the message queue is set to 0.

[0267] Next, the driver layer performs the following steps:

[0268] 1. Get the indication information item in the message queue.

[0269] 2. If the value of the indication information item is 1, it is determined whether the driver layer has completed the configuration of all command words.

[0270] 3. If the configuration of all command words is completed, the sending and receiving of messages can be executed. If the configuration of all command words is not completed, jump to the encapsulation command word to obtain the encapsulation message structure, and send the encapsulation message structure.

[0271] 4. If the values ​​of all indication information items are 0, then end.

[0272] Based on the same inventive concept, a network card operation device corresponding to the network card operation method is also provided in the embodiment of the present application. Since the principle of solving the problem by the device in the embodiment of the present application is similar to the above-mentioned network card operation method in the embodiment of the present application, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.

[0273] Fig.14 This is a schematic diagram of the structure of a network card operating device provided in an embodiment of the present application, which can be integrated into a processor of an electronic device.

[0274] Applied to the processor connected to the target network card, the processor is deployed with a driver layer, a command word general interface layer, and a hardware processing layer, such as Fig.14 As shown, the device may include:

[0275] The processing module 701 is used to perform structured encapsulation on at least one command word of the target network card through the driver layer to obtain an encapsulated message structure of each command word;

[0276] The processing module 701 is further used to call the general interface provided by the command word general interface layer through the driver layer to write the encapsulated message structure into the message queue of the shared memory;

[0277] The acquisition module 702 is used to call the general interface through the hardware processing layer, read the encapsulated message structure from the message queue, and perform structured analysis on the encapsulated message structure to obtain each command word;

[0278] The processing module 701 is also used to perform corresponding operations on the target network card according to each command word through the hardware processing layer.

[0279] In an optional implementation, the processing module 701 is specifically configured to:

[0280] Obtain the main command word and sub-command word corresponding to each command word through the driver layer;

[0281] The driver layer performs structural encapsulation according to the main command word, the sub-command word, and the information item indicating whether the network card operation is successful, thereby obtaining an encapsulated message structure;

[0282] The processing module 701 is specifically used for:

[0283] The hardware processing layer performs corresponding operations on the target network card according to the main command word and the sub-command word.

[0284] In an optional implementation, the acquisition module 702 is further configured to:

[0285] Obtain the operation result of the target network card through the hardware processing layer, the operation result is: operation success or operation failure;

[0286] The processing module 701 is further configured to write the operation result into the indication information item through the hardware processing layer.

[0287] In an optional implementation manner, the network card operation is a network card configuration, and the processing module 701 is further configured to:

[0288] The driver layer performs structured encapsulation according to the main command word, the sub-command word, the indication information item of whether the network card is configured successfully, and the network card configuration parameters to obtain an encapsulated message structure;

[0289] The processing module is specifically used to configure the target network card according to the main command word, the sub-command word and the network card configuration parameters through the hardware processing layer.

[0290] In an optional implementation, the operation result is a network card configuration result, and the acquisition module 702 is further used to:

[0291] Call the general interface through the driver layer to read the network card configuration results from the message queue;

[0292] The transceiver module is used to send and receive messages through the driver layer if the network card configuration result is successful.

[0293] In an optional implementation manner, the network card operation is to obtain the network card configuration, and the processing module 701 is specifically used to:

[0294] The driver layer performs structural encapsulation according to the main command word, the sub-command word, the indication information item of whether the network card configuration is successfully obtained, and the return value indication information item to obtain an encapsulated message structure;

[0295] The processing module 701 is specifically used to obtain the configuration information of the target network card according to the main command word and the sub-command word through the hardware processing layer.

[0296] In an optional implementation, the processing module 701 is further configured to:

[0297] The configuration information of the target network card is written into the return value indication information item through the hardware processing layer.

[0298] In an optional implementation, the operation result is a network card configuration acquisition result, and the acquisition module 702 is further used to:

[0299] Call the general interface through the driver layer to obtain the network card configuration results from the message queue;

[0300] If the network card configuration acquisition result is successful, the configuration information of the target network card is read from the message queue;

[0301] The processing module 701 is further used for:

[0302] The driver layer performs software processing based on the configuration information of the target network card.

[0303] In an optional implementation, the processing module 701 is specifically configured to:

[0304] Determine the current queue index of the message queue pointed to by the tail pointer through the driver layer;

[0305] Call the general interface through the driver layer to write the encapsulated message structure into the message queue according to the current queue index;

[0306] The processing module 701 is further used for:

[0307] The driver layer points the tail pointer to the next queue index of the message queue.

[0308] In an optional implementation, the acquisition module 702 is specifically configured to:

[0309] The hardware processing layer calls the general interface to poll and detect whether the queue index pointed to by the tail pointer is updated;

[0310] If it is detected that the queue index pointed to by the tail pointer is updated, the general interface is called through the hardware processing layer to read the encapsulated message structure from the message queue.

[0311] In an optional implementation, the processing module 701 is specifically configured to:

[0312] Through the hardware processing layer, according to a first command word in the at least one command word, a corresponding network card operation is performed on the target network card;

[0313] The operation result is written into the indication information item through the hardware processing layer, including:

[0314] The operation result of the first command word is written into the information configuration item through the hardware processing layer.

[0315] In an optional implementation, the processing module 701 is specifically configured to:

[0316] After calling the general interface through the driver layer and reading the indication information of the operation result of the first command word from the message queue, the hardware processing layer performs the corresponding network card operation on the target network card according to the next command word of the first command word in at least one command word, until the operation of the target network card is completed based on all command words.

[0317] For descriptions of the processing flow of each module in the device and the interaction flow between each module, reference may be made to the relevant descriptions in the above method embodiment, which will not be described in detail here.

[0318] Fig.15 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application, such as Fig.15 As shown, it includes: a processor 801, a memory 802 and a bus 803. The memory 802 stores machine-readable instructions executable by the processor 801. When the electronic device is running, the processor 801 communicates with the memory 802 through the bus 803, and the processor 801 executes the machine-readable instructions to perform the above method.

[0319] An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. The computer program is executed when a processor is running, and the processor executes the above method.

[0320] In the embodiment of the present application, the computer program can also execute other machine-readable instructions when run by the processor to execute other methods described in the embodiment. For the specific execution method steps and principles, please refer to the description of the embodiment, which will not be repeated here.

[0321] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.

[0322] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0323] In addition, each functional unit in the embodiments provided in the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0324] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0325] It should be noted that similar numbers and letters represent similar items in the following figures. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. In addition, the terms "first", "second", "third", etc. are only used to distinguish the description and are not to be understood as indicating or implying relative importance.

[0326] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present application, which are used to illustrate the technical solutions of the present application, rather than to limit them. The protection scope of the present application is not limited thereto. Although the present application is described in detail with reference to the above-mentioned embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-mentioned embodiments within the technical scope disclosed in the present application, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application. They should all be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.

Claims

1. A network card operation method, characterized in that: Applied to a processor connected to a target network card, the processor is deployed with a driver layer, a command word general interface layer and a hardware processing layer, and the method includes: By means of the driver layer, at least one command word of the target network card is respectively structured and encapsulated to obtain an encapsulated message structure of each command word; Calling the universal interface provided by the command word universal interface layer through the driver layer, writing the encapsulated message structure into the message queue of the shared memory; Calling the universal interface through the hardware processing layer, reading the encapsulated message structure from the message queue, and performing structured analysis on the encapsulated message structure to obtain the command words; The hardware processing layer performs corresponding operations on the target network card according to each command word.

2. The method according to claim 1, characterized in that The step of performing structured encapsulation on at least one command word of the target network card through the driver layer to obtain an encapsulated message structure of each command word includes: Acquire the main command word and the sub-command word corresponding to each command word through the driver layer; The driver layer performs structural encapsulation according to the main command word, the sub-command word, and the indication information item of whether the network card operation is successful, to obtain the encapsulated message structure; The performing corresponding operations on the target network card according to the command word through the hardware processing layer includes: The hardware processing layer performs corresponding operations on the target network card according to the main command word and the sub-command word.

3. The method according to claim 2, characterized in that The method further comprises: Acquire the operation result of the target network card through the hardware processing layer, the operation result being: operation success or operation failure; The operation result is written into the indication information item through the hardware processing layer.

4. The method according to claim 3, characterized in that The network card operation is a network card configuration, and the driver layer performs structured encapsulation according to the main command word, the sub-command word, and the indication information item of whether the network card operation is successful to obtain the encapsulated message structure, including: The driver layer performs structured encapsulation according to the main command word, the sub-command word, the indication information item of whether the network card is configured successfully, and the network card configuration parameters to obtain the encapsulated message structure; The performing corresponding operations on the target network card according to the main command word and the sub-command word through the hardware processing layer includes: The target network card is configured through the hardware processing layer according to the main command word, the sub-command word and the network card configuration parameters.

5. The method according to claim 4, characterized in that The operation result is a network card configuration result, and the method further includes: Calling the universal interface through the driver layer to read the network card configuration result from the message queue; If the network card configuration result is successful, the message is sent and received through the driver layer.

6. The method according to claim 3, characterized in that The network card operation is to obtain the network card configuration, and the driver layer performs structured encapsulation according to the main command word, the sub-command word, and the indication information item of whether the network card operation is successful to obtain the encapsulated message structure, including: The driver layer performs structural encapsulation according to the main command word, the sub-command word, the indication information item of whether the network card configuration is successfully obtained, and the return value indication information item to obtain the encapsulated message structure; The performing corresponding network card operations on the target network card according to the command word through the hardware processing layer includes: The configuration information of the target network card is obtained through the hardware processing layer according to the main command word and the sub-command word.

7. The method according to claim 6, characterized in that The method further comprises: The configuration information of the target network card is written into the return value indication information item through the hardware processing layer.

8. The method according to claim 7, characterized in that The operation result is a network card configuration acquisition result, and the method further includes: Calling the general interface through the driver layer to obtain the network card configuration acquisition result from the message queue; If the network card configuration acquisition result is successful, reading the configuration information of the target network card from the message queue; The driver layer performs software processing according to the configuration information of the target network card.

9. The method according to claim 1, characterized in that: The step of calling the universal interface provided by the command word universal interface layer through the driver layer to write the encapsulated message structure into a message queue of a shared memory includes: Determine, by the driver layer, the current queue index of the message queue pointed to by the tail pointer; Calling the general interface through the driver layer to write the encapsulated message structure into the message queue according to the current queue index; The method further comprises: The driver layer points the queue tail pointer to the next queue index of the message queue.

10. The method according to claim 9, characterized in that The calling the general interface through the hardware processing layer to read the encapsulated message structure from the message queue includes: Calling the general interface polling through the hardware processing layer to detect whether the queue index pointed to by the tail pointer is updated; If it is detected that the queue index pointed to by the tail pointer is updated, the general interface is called through the hardware processing layer to read the encapsulated message structure from the message queue.

11. The method according to claim 3, characterized in that The performing corresponding network card operations on the target network card according to each command word through the hardware processing layer includes: Through the hardware processing layer, according to a first command word in the at least one command word, performing a corresponding network card operation on the target network card; The step of writing the operation result into the indication information item through the hardware processing layer includes: The operation result of the first command word is written into the information configuration item through the hardware processing layer.

12. The method according to claim 11, characterized in that The performing corresponding network card operations on the target network card according to the command word through the hardware processing layer includes: After calling the universal interface through the driver layer and reading the indication information of the operation result of the first command word from the message queue, the hardware processing layer performs the corresponding network card operation on the target network card according to the next command word of the first command word in the at least one command word, until the operation of the target network card is completed based on all command words.

13. The method according to claim 1, characterized in that Before respectively performing structured encapsulation on at least one command word of the target network card through the driver layer to obtain an encapsulated message structure of each command word, the method further includes: Mapping the physical address of the target network card through the driver layer to obtain the virtual address of the target network card; Constructing a network card structure of the target network card according to the physical address of the target network card and the virtual address of the target network card through the driver layer; The calling attribute of the network card structure is set by the driver layer, and the calling attribute is used to indicate that the network card structure is private data called by the kernel of the processor.

14. The method according to claim 5, characterized in that Before sending and receiving messages through the driver layer, the method further includes: Establishing a mapping relationship between the receiving and sending queue of the driver layer and the receiving and sending queue of the target network card through the driver layer; The sending and receiving of messages through the driver layer includes: Messages are sent and received through the driver layer according to the mapping relationship.

15. A network card operating device, characterized in that: Applied to a processor connected to a target network card, the processor is deployed with a driver layer, a command word general interface layer and a hardware processing layer, and the device includes: A processing module, used for performing structured encapsulation on at least one command word of the target network card through the driver layer to obtain an encapsulated message structure of each command word; The processing module is further used to call the universal interface provided by the command word universal interface layer through the driver layer to write the encapsulated message structure into the message queue of the shared memory; An acquisition module, used for calling the universal interface through the hardware processing layer, reading the encapsulated message structure from the message queue, and performing structured analysis on the encapsulated message structure to obtain the command words; The processing module is further used to perform corresponding operations on the target network card according to the command words through the hardware processing layer.

16. An electronic device, characterized in that: include: A processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate via the bus, and the processor executes the machine-readable instructions to perform the method described in any one of claims 1 to 14.

17. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 14 is executed.