[go: up one dir, main page]

CN119135534A - DPDK dynamic network card adding method, storage medium, electronic device and program product - Google Patents

DPDK dynamic network card adding method, storage medium, electronic device and program product Download PDF

Info

Publication number
CN119135534A
CN119135534A CN202411165983.4A CN202411165983A CN119135534A CN 119135534 A CN119135534 A CN 119135534A CN 202411165983 A CN202411165983 A CN 202411165983A CN 119135534 A CN119135534 A CN 119135534A
Authority
CN
China
Prior art keywords
network card
event
dpdk
network
xdp
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202411165983.4A
Other languages
Chinese (zh)
Inventor
杨强
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Topsec Technology Co Ltd
Beijing Topsec Network Security Technology Co Ltd
Beijing Topsec Software Co Ltd
Original Assignee
Beijing Topsec Technology Co Ltd
Beijing Topsec Network Security Technology Co Ltd
Beijing Topsec Software Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Topsec Technology Co Ltd, Beijing Topsec Network Security Technology Co Ltd, Beijing Topsec Software Co Ltd filed Critical Beijing Topsec Technology Co Ltd
Priority to CN202411165983.4A priority Critical patent/CN119135534A/en
Publication of CN119135534A publication Critical patent/CN119135534A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/08Configuration management of networks or network elements
    • H04L41/0803Configuration setting
    • H04L41/0823Configuration setting characterised by the purposes of a change of settings, e.g. optimising configuration for enhancing reliability
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/16Implementation or adaptation of Internet protocol [IP], of transmission control protocol [TCP] or of user datagram protocol [UDP]
    • H04L69/161Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields
    • H04L69/162Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields involving adaptations of sockets based mechanisms

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The application provides a DPDK dynamic network card adding method, a storage medium, an electronic device and a program product, which are characterized in that a network card adding event sent by a monitoring kernel is used for calling a corresponding network card adding event processing function, and processing the dynamically added network card in real time, wherein in the process of dynamically adding the network card to the DPDK, the whole DPDK process does not need to be restarted, so that the network communication of the existing network card equipment is not affected. Also, DPDK can significantly reduce packet processing delay using af_xdp sockets. AF XDP is an efficient packet reception mechanism that allows applications to directly access the queues of the network hardware, bypassing the kernel protocol stack, thereby reducing CPU consumption and delay. By creating and binding an AF_XDP socket for each network card queue, finer granularity data packet processing can be realized, and the parallel processing capability is improved.

Description

DPDK dynamic network card adding method, storage medium, electronic device and program product
Technical Field
The application relates to the technical field of network communication, in particular to a method for adding a DPDK dynamic network card, a storage medium, electronic equipment and a program product.
Background
The DPDK (DATA PLANE Development Kit) is an open-source Development platform and interface for rapidly processing data plane data packet forwarding, and realizes high-performance message forwarding capability under an x86 processor architecture through a plurality of technologies such as an environment abstraction layer, a bypass kernel protocol stack, message uninterrupted transceiving of a polling mode, optimization of memory/buffer/queue management, load balancing based on network card multi-queue and stream identification, and the like.
First, the Environment Abstraction Layer (EAL) provides a uniform, low latency interface for DPDK applications to access underlying hardware resources such as CPU cores, memory and Network Interface Cards (NICs), thereby bypassing certain limitations of conventional operating system kernels and reducing the overhead of context switching and data copying.
Secondly, the DPDK adopts a strategy of bypassing a kernel protocol stack, namely, the network data packet is directly processed in a user mode, so that multiple memory copies and CPU interruption in the traditional network stack are avoided, and real Zero-Copy (Zero-Copy) and efficient data packet processing are realized. This design not only reduces latency, but also significantly improves the throughput of the system.
In terms of messaging, DPDK introduces a polling mode (Polling Mode Driver, PMD) to receive and transmit data packets by polling rather than by interrupts. This reduces the idle latency of the CPU and allows applications to handle network events with higher frequency and lower latency.
In addition, DPDK further improves the efficiency of data packet processing by optimizing memory, buffer and queue management strategies. It provides efficient data structures such as a loopless ring buffer (Ring Buffers) and memory pool (Memory Pools) to support fast packet access and reuse, reducing overhead for memory allocation and release.
In the aspect of load balancing, the DPDK fully utilizes the multi-queue characteristic of the modern network card, and combines the flow identification technology to realize intelligent load balancing based on the flow characteristic and the application requirement. This helps to distribute the processing pressure, improving the overall performance and scalability of the system.
In high performance network servers, network function virtualization scenarios, DPDK is typically used for packet processing and forwarding. When the system needs to expand its network functions, such as implementing load balancing, high availability, etc., a new network card may need to be added to increase the capacity of the network and improve the forwarding performance. We therefore need to support DPDK dynamic addition of network cards.
The method for dynamically adding the network card is used at present, namely the newly added network card is bound to a DPDK driver, and then the network service of the DPDK is restarted or the whole DPDK is restarted, and the method can cause network interruption of the existing interface of the DPDK in the restarting process, so that network communication is influenced.
Disclosure of Invention
The embodiment of the application aims to provide a DPDK dynamic network card adding method, a storage medium, electronic equipment and a program product, which are used for solving the technical problem that the network of a DPDK existing interface is interrupted in the restarting process caused by the existing network card dynamic adding method.
The method for adding the DPDK dynamic network card provided by the embodiment of the application comprises the following steps:
Monitoring an added network card event by using a network card equipment event monitoring module;
calling an event processing function for adding a network card by using hotplug modules of the DPDK;
Distributing available PORT IDs for the added network cards;
And starting the network card, and carrying out packet receiving and transmitting operation on the corresponding network card queue by using the AF_XDP socket according to the corresponding relation among the PORT ID of the newly built network card, the network card queue and the AF_XDP socket.
According to the technical scheme, the dynamically added network card is processed in real time by monitoring the network card adding event sent by the kernel and calling the corresponding network card adding event processing function, and the whole DPDK process is not required to be restarted in the process of dynamically adding the network card by the DPDK, so that network communication of the existing network card equipment is not affected. Also, DPDK can significantly reduce packet processing delay using af_xdp sockets. AF XDP is an efficient packet reception mechanism that allows applications to directly access the queues of the network hardware, bypassing the kernel protocol stack, thereby reducing CPU consumption and delay. By creating and binding an AF_XDP socket for each network card queue, finer granularity data packet processing can be realized, and the parallel processing capability is improved.
In some optional embodiments, before the adding of the network card event is monitored, the method further includes:
and initializing DPDK, and starting a thread for creating the network card equipment event monitoring module.
In the technical scheme, the special thread is started to create and manage the network card equipment event monitoring module, so that the module can be ensured to run independently of the main program, the influence on the performance of the main program is reduced, and the stability and the reliability of the system are improved. In addition, the network card device event is monitored through a special thread, the event such as network card addition and removal can be responded more quickly, and the instant response capability is particularly important for network applications requiring high real-time performance.
In some alternative embodiments, creating a network card device event monitoring module includes:
creating udev monitoring sockets for monitoring the event data of the kernel sending network card equipment;
Configuring a network card equipment event monitoring module, and analyzing the network card equipment event data to obtain event types and equipment information when the kernel transmits the network card equipment event data to udev monitoring sockets;
In some alternative embodiments, wherein the event types include adding a network card event and removing a network card event.
In some alternative embodiments, the device information includes a network card name.
In the above technical solution, udev is a device manager of the linux kernel, which can dynamically update a device file according to a state of a hardware device in a system, including creation, deletion, and the like of the device file. The udev library provides an API interface to monitor network card events, and performs corresponding hot plug actions by monitoring uevent sent by the kernel. By udev monitoring the socket, the system can receive the event data of the network card device sent by the kernel in real time. This mechanism ensures that the system can respond almost immediately to the addition or removal of the network card device, thereby improving the timeliness and accuracy of event processing. The event data of the network card equipment is analyzed, the event type (such as adding a network card or removing the network card) and specific equipment information (such as a network card name) can be accurately identified, and corresponding processing logic can be executed according to different event types subsequently, so that the flexibility and the adaptability of the system are improved.
In some alternative embodiments, before the adding the network card event processing function is invoked by using hotplug module of the DPDK, the method further includes:
initializing hotplug a module, and starting hotplug a processing mechanism to monitor and respond to network card equipment event data from the kernel;
And registering callback functions corresponding to different event types, wherein the callback functions are used for being called when network card equipment events of the corresponding event types occur.
In some optional embodiments, the event types include adding a network card event and removing a network card event, a callback function corresponding to the adding of the network card event is an adding network card event processing function, and a callback function corresponding to the removing of the network card event is a removing network card event processing function.
In the above technical solution, when a new network card device is added to the system, the system can automatically call the add network card event processing function to configure the device. This includes the operations of allocating PORT ID, configuring the number of network card queues, binding af_xdp sockets, etc. Likewise, when the network card device is removed, the system can also automatically call the remove network card event processing function to release the relevant resources. By initializing hotplug modules of the DPDK and starting the processing mechanism thereof, the effects of high integration, event driving, automation processing, stability and reliability improvement, dynamic network configuration support, resource utilization optimization and the like are brought.
The embodiment of the application provides a dynamic network card adding device based on DPDK, which comprises the following components:
the monitoring component is used for monitoring the network card event by using the network card equipment event monitoring module;
The calling component is used for calling the network card event processing function by utilizing the hotplug module of the DPDK;
The distribution component is used for distributing available PORT IDs for the added network cards;
The processing component is used for configuring the network card queue number enabled by the network card by adding the network card event processing function, creating and binding an AF_XDP socket for each network card queue enabled by the network card, starting the network card, and carrying out packet receiving and transmitting operations on the corresponding network card queue by using the AF_XDP socket according to the corresponding relation between the PORT ID of the newly-built network card, the network card queue and the AF_XDP socket.
In some alternative embodiments, further comprising:
and the configuration component is used for initializing the DPDK and starting a thread for creating the network card equipment event monitoring module.
In some alternative embodiments, the configuration component is further configured to:
creating udev monitoring sockets for monitoring the event data of the kernel sending network card equipment;
And configuring a network card equipment event monitoring module, and analyzing the network card equipment event data to obtain event types and equipment information when the kernel transmits the network card equipment event data to udev monitoring sockets, wherein the event types comprise adding network card events and removing network card events, and the equipment information comprises network card names.
In some alternative embodiments, the configuration component is further configured to:
initializing hotplug a module, and starting hotplug a processing mechanism to monitor and respond to network card equipment event data from the kernel;
Registering callback functions corresponding to different event types, wherein the callback functions are used for being called when network card equipment events of corresponding event types occur, the event types comprise adding network card events and removing network card events, the callback functions corresponding to the adding network card events are added network card event processing functions, and the callback functions corresponding to the removing network card events are removed network card event processing functions.
A computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs a method as described in any of the above.
An electronic device provided in an embodiment of the present application includes a processor and a memory storing machine-readable instructions executable by the processor, which when executed by the processor, perform a method as described in any of the above.
A computer program product according to an embodiment of the present application comprises a computer program/instruction which, when executed by a processor, implements the steps of any of the methods described above.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the embodiments of the present application will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present application and should not be considered as limiting the scope, and other related drawings can be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a flowchart of steps of a method for adding a DPDK dynamic network card according to an embodiment of the present application;
Fig. 2 is a functional block diagram of a DPDK-based dynamic network card adding device according to an embodiment of the present application;
fig. 3 is a schematic diagram of a possible structure of an electronic device according to an embodiment of the application.
The icons are 1-configuration component, 2-monitoring component, 3-calling component, 4-allocation component, 5-processing component, 61-processor, 62-memory, 63-communication interface, 64-communication bus.
Detailed Description
The technical solutions in the embodiments of the present application will be described below with reference to the accompanying drawings in the embodiments of the present application.
Referring to fig. 1, fig. 1 is a flowchart illustrating steps of a method for adding a DPDK dynamic network card according to an embodiment of the present application, where the method includes:
Step S1, a network card event is monitored by using a network card equipment event monitoring module;
The network card device event monitoring module may use an API interface provided by the udev library for monitoring network card events, and execute a corresponding hot plug action by monitoring uevent sent by the kernel. udev is a linux kernel device manager that can dynamically update device files according to the state of hardware devices in the system, including creation, deletion, etc. of device files.
S2, calling an event processing function of the added network card by utilizing a hotplug module of the DPDK;
step S3, distributing available PORT IDs for the added network cards;
and S4, configuring the network card enabled network card queue number for the added network card by adding the network card event processing function, creating and binding an AF_XDP socket for each network card queue enabled by the network card, starting the network card, and carrying out packet receiving and transmitting operations on the corresponding network card queue by using the AF_XDP socket according to the corresponding relation between the PORT ID of the newly-built network card, the network card queue and the AF_XDP socket.
Wherein, AF_XDP is one of protocol families, which is used for specifying the type of socket communication, and we use socket () system call to create an AF_XDP socket (XSK), and then call bind () system function to bind the AF_XDP socket created before with the network card. Each XSK has two RINGs, RX RING and TX RING. Application calls recv () function may receive packets on the RX RING and send () function may send packets on the TX RING RING. These loops are registered and resized by the XDP_RX_RING and XDP_TX_RING of setockopts (), respectively. The RX RING and the TX RING can be shared in the user mode and the memory mode by calling the mmap () function, so that data packets do not need to be copied in the kernel mode and the user mode, and the performance is improved. The principle of the AF_XDP socket is that after the data packet reaches the XDP network hook point of the network card, the data packet is stored in the RX RING, the application program calls recv () system function, the data packet is obtained from the RX RING through the AF_XDP socket, the application program calls send (), and the transmitted data packet is stored in the TX RING through the AF_XDP socket.
Socket is a basic concept in computer network communications, which is an abstract data structure used to provide a communication interface between network applications. A socket may be considered an endpoint for sending and receiving data such that applications running on different machines can exchange information to implement network functions.
In the embodiment of the application, the dynamically added network card is processed in real time by monitoring the network card adding event sent by the kernel and calling the corresponding network card adding event processing function, and the whole DPDK process is not required to be restarted in the process of dynamically adding the network card by the DPDK, so that the network communication of the existing network card equipment is not influenced. Also, DPDK can significantly reduce packet processing delay using af_xdp sockets. AF XDP is an efficient packet reception mechanism that allows applications to directly access the queues of the network hardware, bypassing the kernel protocol stack, thereby reducing CPU consumption and delay. By creating and binding an AF_XDP socket for each network card queue, finer granularity data packet processing can be realized, and the parallel processing capability is improved.
In some optional embodiments, before the adding of the network card event is monitored, the method further includes:
and initializing DPDK, and starting a thread for creating the network card equipment event monitoring module.
In the embodiment of the application, the special thread is started to create and manage the event monitoring module of the network card equipment, so that the module can be ensured to run independently of the main program, the influence on the performance of the main program is reduced, and the stability and the reliability of the system are improved. In addition, the network card device event is monitored through a special thread, the event such as network card addition and removal can be responded more quickly, and the instant response capability is particularly important for network applications requiring high real-time performance.
In some alternative embodiments, creating a network card device event monitoring module includes:
creating udev monitoring sockets for monitoring the event data of the kernel sending network card equipment;
And configuring a network card equipment event monitoring module, and analyzing the network card equipment event data to obtain event types and equipment information when the kernel transmits the network card equipment event data to udev monitoring sockets, wherein the event types comprise adding network card events and removing network card events, and the equipment information comprises network card names.
In the embodiment of the present application udev is a device manager of a linux kernel, which can dynamically update a device file according to the state of a hardware device in a system, including creation, deletion, etc. of the device file. The udev library provides an API interface to monitor network card events, and performs corresponding hot plug actions by monitoring uevent sent by the kernel. By udev monitoring the socket, the system can receive the event data of the network card device sent by the kernel in real time. This mechanism ensures that the system can respond almost immediately to the addition or removal of the network card device, thereby improving the timeliness and accuracy of event processing. The event data of the network card equipment is analyzed, the event type (such as adding a network card or removing the network card) and specific equipment information (such as a network card name) can be accurately identified, and corresponding processing logic can be executed according to different event types subsequently, so that the flexibility and the adaptability of the system are improved.
Specifically, the DPDK is initialized, a thread is started, and an API interface of udev library is used to monitor the hot plug event of the network card, including the following steps:
Step S11, creating udev a monitoring socket, which is completed by calling udev _monitor_new_from_network () function, and the function creates a monitoring socket for monitoring event data of the network card device sent by the kernel.
And step S12, receiving network card equipment events, namely when events such as network card hot plug, network card equipment state change and the like occur, the kernel sends network card equipment event data to the monitoring socket. The network card device event monitoring thread uses the read () function to read event data from the socket.
And S13, analyzing the network card equipment event, wherein the received network card equipment data event needs to be analyzed to determine the type of the event and related equipment information. The event type comprises network card addition, network card removal and the like, and the equipment information comprises network card names and the like. Which will be used in the subsequent steps.
In some alternative embodiments, before the adding the network card event processing function is invoked by using hotplug module of the DPDK, the method further includes:
initializing hotplug a module, and starting hotplug a processing mechanism to monitor and respond to network card equipment event data from the kernel;
Registering callback functions corresponding to different event types, wherein the callback functions are used for being called when network card equipment events of corresponding event types occur, the event types comprise adding network card events and removing network card events, the callback functions corresponding to the adding network card events are added network card event processing functions, and the callback functions corresponding to the removing network card events are removed network card event processing functions.
In the embodiment of the application, when a new network card device is added into the system, the system can automatically call the network card event adding processing function to configure the device. This includes the operations of allocating PORT ID, configuring the number of network card queues, binding af_xdp sockets, etc. Likewise, when the network card device is removed, the system can also automatically call the remove network card event processing function to release the relevant resources. By initializing hotplug modules of the DPDK and starting the processing mechanism thereof, the effects of high integration, event driving, automation processing, stability and reliability improvement, dynamic network configuration support, resource utilization optimization and the like are brought.
Specifically, the hotplug module of the DPDK is a network card device event processing framework provided by the DPDK, and when a network card event occurs, the functional module focusing on the network card event is notified through the framework. After the monitoring network card hot plug event is initialized by the DPDK, registering a network card equipment hot plug event processing function, wherein the processing function is a newly added network card binding AF_XDP socket, and the method comprises the following steps of:
And step S21, firstly, rte _dev_ hotplug _handle_enable (), initializing a network card device event processing framework, and then, calling rte _dev_event_callback_register (), and registering a network card device hot plug event processing function.
Step S22, analyzing the message and processing according to the message type, if the name of the network card is obtained and the network card EVENT is a newly added network card, then RTE _dev_event_call_process () is adjusted, a network card hot plug EVENT is sent, and the EVENT type is RTE_DEV_event_ADD and the name of the network card.
And S23, when rte _dev_event_call_process () function is adjusted, the hot plug event processing function of the registered network card device is adjusted, and the processing function is the queue binding AF_XDP socket of the newly added network card.
After the network card device event monitoring module creates and registers an event processing function, when a newly created network card event occurs, the network card device event processing framework of the hotplug module of the DPDK adjusts the registered device hot plug event processing function, and the processing function initializes a network card queue and starts the network card.
The implementation steps are as follows:
in step S31, when the DPDK operates the network card, the network card is indirectly operated by the PORT ID number, firstly, an available PORT ID is allocated to the network card, and the correspondence between the PORT ID and the network card name is recorded.
And S32, setting the number of network card queues, namely acquiring the name of the newly added network card by the device hot plug event processing function, and calling setsockopt () to configure the number of queues enabled by the network card. The number of queues that each network card can enable can be configured at the start of DPDK.
S33, create af_xdp socket (XSK) for the network card, create af_xdp socket for each queue enabled by the network card using socket () system call.
S34, binding the socket to the network card queue, namely binding the socket XSK to the specific network card queue by using bind (), and recording the corresponding relation of the socket XSK, the network card PORT ID and the network card queue.
And S35, after the work is finished, the DPDK starts the network card, and the AF_XDP socket can be used for receiving and transmitting packets on each queue of the network card, so that the forwarding of the network data packet is finished.
In summary, in this embodiment, through udev, the hot plug event of the network card is monitored, and the related event processing function is invoked to process the dynamically added network card in real time. And the function of receiving and transmitting packets on the newly added network card is realized by means of the AF_XDP technology, so that the network card is dynamically added to the DPDK under the condition that the DPDK process is not required to be restarted.
The dynamic network card adding method of the embodiment can be used for the bottom layer drainage of the secure resource pool and the dynamic network card adding flow of the virtualized secure network element, taking the virtualized secure network element as an example, the flow is as follows:
when the DPDK process of the virtualized security network element is started, the maximum queue number enabled by the dynamically added network card is set according to the requirement.
When the DPDK process of the virtualized security network element is started, a thread is started to monitor the hot plug event of the network card.
When the DPDK process of the virtualized security network element is started, initializing a network card event processing framework, and then registering a device hot plug event processing function.
The DPDK process of the virtualized security network element allocates a PORT ID for the network card.
The DPDK process of the virtualized security network element initializes a network card queue for the newly added network card, creates an AF_XDP socket for each enabled queue, and records the corresponding relation between the created AF_XDP socket and the network card queue.
The DPDK process of the virtualized security network element starts the network card.
The DPDK process of the virtualized security network element calls a packet receiving and transmitting interface rte _eth_rx_burst () and rte _eth_tx_burst () to receive and transmit packets, and the interface finds the AF_XDP socket to which the packet belongs according to the transmitted parameter PORT ID and the queue number, so that the packet receiving and transmitting on each queue of the network card is realized, and the forwarding of network data packets is completed.
Referring to fig. 2, fig. 2 is a functional block diagram of a DPDK-based dynamic network card adding device according to an embodiment of the present application, which includes a monitoring component 2, an allocating component 4, a calling component 3, and a processing component 5.
The network interface device comprises a monitoring component 2, a calling component 3, an allocation component 4, a processing component 5 and a network interface starting component, wherein the monitoring component 2 is used for monitoring an added network interface event by using a network interface device event monitoring module, the calling component 3 is used for calling an added network interface event processing function by using a hotplug module of a DPDK, the allocation component 4 is used for allocating available PORT IDs for the added network interface, the processing component 5 is used for configuring network interface enabled network interface queues for the added network interface by adding the network interface event processing function, creating and binding an AF_XDP socket for each network interface enabled network interface queue, and starting the network interface, and carrying out packet receiving and transmitting operations on the corresponding network interface queues by using the AF_XDP socket according to the correspondence between the PORT ID, the network interface queues and the AF_XDP socket of the newly-built network interface.
In some alternative embodiments, the system further comprises a configuration component 1 for initializing the DPDK and starting a thread for creating the network card device event monitoring module.
In some optional embodiments, the configuration component 1 is further configured to create udev monitoring sockets for monitoring the kernel to send event data of the network card device, configure the event monitoring module of the network card device, and parse the event data of the network card device to obtain event types and device information when the kernel sends the event data of the network card device to udev monitoring sockets, where the event types include adding the event of the network card and removing the event of the network card, and the device information includes a name of the network card.
In some optional embodiments, the configuration component 1 is further configured to initialize hotplug a module, start hotplug a processing mechanism to monitor and respond to event data of the network card device from the kernel, register callback functions corresponding to different event types, where the callback functions are used to be invoked when an event of the network card device corresponding to the event type occurs, the event type includes adding the network card event and removing the network card event, adding the callback functions corresponding to the network card event as an added network card event processing function, and removing the callback functions corresponding to the network card event as a removed network card event processing function.
Fig. 3 shows a possible structure of the electronic device provided by the embodiment of the application. Referring to fig. 3, the electronic device includes a processor 61, a memory 62, and a communication interface 63, which are interconnected and communicate with each other by a communication bus 64 and/or other forms of connection mechanisms (not shown).
The Memory 62 includes one or more (Only one is shown in the figure), which may be, but is not limited to, a random access Memory (Random Access Memory, abbreviated as RAM), a Read Only Memory (ROM), a programmable Read Only Memory (Programmable Read-Only Memory, abbreviated as PROM), an erasable programmable Read Only Memory (Erasable Programmable Read-Only Memory, abbreviated as EPROM), an electrically erasable programmable Read Only Memory (Electric Erasable Programmable Read-Only Memory, abbreviated as EEPROM), and the like. The processor 61 and possibly other components may access the memory 62, read and/or write data therein.
The processor 61 comprises one or more (only one shown) which may be an integrated circuit chip with signal processing capabilities. The Processor 61 may be a general-purpose Processor including a central processing unit (Central Processing Unit, CPU), a micro control unit (Micro Controller Unit, MCU), a network Processor (Network Processor, NP) or other conventional processors, or may be a special-purpose Processor including a neural network Processor (Neural-network Processing Unit, NPU), a graphics Processor (Graphics Processing Unit, GPU), a digital signal Processor (DIGITAL SIGNAL Processor, DSP), an Application SPECIFIC INTEGRATED Circuits (ASIC), a field programmable gate array (Field Programmable GATE ARRAY, FPGA) or other programmable logic device, discrete gate or transistor logic device, or discrete hardware components. Also, when the processor 61 is plural, some of them may be general-purpose processors, and the other may be special-purpose processors.
Communication interface 63 includes one or more (only one shown) that may be used to communicate directly or indirectly with other devices for data interaction. Communication interface 63 may include an interface for wired and/or wireless communication.
One or more computer program instructions may be stored in memory 62 that may be read and executed by processor 61 to implement the methods provided by embodiments of the present application.
It will be appreciated that the configuration shown in fig. 3 is merely illustrative, and that the electronic device may also include more or fewer components than shown in fig. 3, or have a different configuration than shown in fig. 3. The components shown in fig. 3 may be implemented in hardware, software, or a combination thereof. The electronic device may be a physical device such as a PC, a notebook, a tablet, a cell phone, a server, an embedded device, etc., or may be a virtual device such as a virtual machine, a virtualized container, etc. The electronic device is not limited to a single device, and may be a combination of a plurality of devices or a cluster of a large number of devices.
A computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs a method as described in any of the above.
A computer program product according to an embodiment of the present application comprises a computer program/instruction which, when executed by a processor, implements the steps of any of the methods described above.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other manners. The above-described apparatus embodiments are merely illustrative, for example, the division of the units is merely a logical function division, and there may be other manners of division in actual implementation, and for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be through some communication interface, device or unit indirect coupling or communication connection, which may be in electrical, mechanical or other form.
Further, the units described as separate units may or may not be physically separate, and units displayed as units may or may not be physical units, may be located in one place, or may be distributed over a plurality of 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.
Furthermore, functional modules in various embodiments of the present application may be integrated together to form a single portion, or each module may exist alone, or two or more modules may be integrated to form a single portion.
In this document, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions.
The above description is only an example of the present application and is not intended to limit the scope of the present application, and various modifications and variations will be apparent to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the protection scope of the present application.

Claims (10)

1.一种DPDK动态网卡添加方法,其特征在于,所述方法包括:1. A DPDK dynamic network card adding method, characterized in that the method comprises: 利用网卡设备事件监测模块,监测到添加网卡事件;Use the network card device event monitoring module to monitor the event of adding a network card; 利用DPDK的hotplug模块,调用添加网卡事件处理函数;Use the hotplug module of DPDK to call the function of adding network card event processing; 为添加的网卡分配可用的PORT ID;Assign an available PORT ID to the added network card; 通过添加网卡事件处理函数,对添加的网卡配置网卡使能的网卡队列数,对网卡使能的每个网卡队列都创建并绑定AF_XDP套接字;并启动网卡,根据新建网卡的PORT ID、网卡队列和AF_XDP套接字的对应关系,使用AF_XDP套接字在对应的网卡队列上进行收包和发包操作。By adding a network card event processing function, the number of network card queues enabled by the added network card is configured, and an AF_XDP socket is created and bound to each network card queue enabled by the network card; and the network card is started, and according to the corresponding relationship between the PORT ID of the newly created network card, the network card queue and the AF_XDP socket, the AF_XDP socket is used to receive and send packets on the corresponding network card queue. 2.如权利要求1所述的方法,其特征在于,所述利用网卡设备事件监测模块,监测到添加网卡事件之前,还包括:2. The method according to claim 1, characterized in that, before the network card device event monitoring module is used to monitor the event of adding a network card, it also includes: DPDK初始化,启动用于创建网卡设备事件监测模块的线程。DPDK is initialized and the thread used to create the network card device event monitoring module is started. 3.如权利要求2所述的方法,其特征在于,所述创建网卡设备事件监测模块,包括:3. The method according to claim 2, wherein the step of creating a network card device event monitoring module comprises: 创建用于监听内核发送网卡设备事件数据的udev监控套接字;Create a udev monitoring socket for monitoring the kernel to send network card device event data; 配置网卡设备事件监测模块,当内核将网卡设备事件数据发送到udev监控套接字时,对网卡设备事件数据进行解析,得到事件类型和设备信息。Configure the network card device event monitoring module. When the kernel sends the network card device event data to the udev monitoring socket, parse the network card device event data to obtain the event type and device information. 4.如权利要求3所述的方法,其特征在于,其中,所述事件类型包括添加网卡事件和移除网卡事件。4. The method according to claim 3, wherein the event type comprises a network card adding event and a network card removing event. 5.如权利要求3所述的方法,其特征在于,其中,所述设备信息包括网卡名称。5. The method according to claim 3, wherein the device information includes a network card name. 6.如权利要求1所述的方法,其特征在于,所述利用DPDK的hotplug模块,调用添加网卡事件处理函数之前,还包括:6. The method according to claim 1, characterized in that, before calling the add network card event processing function using the hotplug module of DPDK, it also includes: 初始化hotplug模块,启动hotplug处理机制,以监听和响应来自内核的网卡设备事件数据;Initialize the hotplug module and start the hotplug processing mechanism to monitor and respond to the network card device event data from the kernel; 注册不同事件类型对应的回调函数,回调函数用于在对应事件类型的网卡设备事件发生时被调用。Register callback functions corresponding to different event types. The callback functions are used to be called when network card device events of the corresponding event types occur. 7.如权利要求6所述的方法,其特征在于,其中,所述事件类型包括添加网卡事件和移除网卡事件,所述添加网卡事件对应的回调函数为添加网卡事件处理函数,所述移除网卡事件对应的回调函数为移除网卡事件处理函数。7. The method as claimed in claim 6 is characterized in that, wherein the event types include an add network card event and a remove network card event, the callback function corresponding to the add network card event is an add network card event processing function, and the callback function corresponding to the remove network card event is a remove network card event processing function. 8.一种计算机可读存储介质,其特征在于,该存储介质上存储有计算机程序,该计算机程序被处理器运行时执行如权利要求1-7任一所述的方法。8. A computer-readable storage medium, characterized in that a computer program is stored on the storage medium, and when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is executed. 9.一种电子设备,其特征在于,包括:处理器和存储器,所述存储器存储有所述处理器可执行的机器可读指令,所述机器可读指令被所述处理器执行时执行如权利要求1-7任一所述的方法。9. An electronic device, comprising: a processor and a memory, wherein the memory stores machine-readable instructions executable by the processor, and when the machine-readable instructions are executed by the processor, the method according to any one of claims 1 to 7 is performed. 10.一种计算机程序产品,包括计算机程序/指令,其特征在于,该计算机程序/指令被处理器执行时实现权利要求1-7任一所述方法的步骤。10. A computer program product, comprising a computer program/instruction, characterized in that when the computer program/instruction is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
CN202411165983.4A 2024-08-23 2024-08-23 DPDK dynamic network card adding method, storage medium, electronic device and program product Pending CN119135534A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202411165983.4A CN119135534A (en) 2024-08-23 2024-08-23 DPDK dynamic network card adding method, storage medium, electronic device and program product

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202411165983.4A CN119135534A (en) 2024-08-23 2024-08-23 DPDK dynamic network card adding method, storage medium, electronic device and program product

Publications (1)

Publication Number Publication Date
CN119135534A true CN119135534A (en) 2024-12-13

Family

ID=93760950

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202411165983.4A Pending CN119135534A (en) 2024-08-23 2024-08-23 DPDK dynamic network card adding method, storage medium, electronic device and program product

Country Status (1)

Country Link
CN (1) CN119135534A (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114244560A (en) * 2021-11-10 2022-03-25 奇安信科技集团股份有限公司 Traffic processing method and device
CN117793034A (en) * 2023-12-27 2024-03-29 北京天融信网络安全技术有限公司 Network card adding method, device, computing equipment and machine-readable storage medium
WO2024159963A1 (en) * 2023-02-01 2024-08-08 天翼云科技有限公司 Local domain name system server optimization method and related device

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114244560A (en) * 2021-11-10 2022-03-25 奇安信科技集团股份有限公司 Traffic processing method and device
WO2024159963A1 (en) * 2023-02-01 2024-08-08 天翼云科技有限公司 Local domain name system server optimization method and related device
CN117793034A (en) * 2023-12-27 2024-03-29 北京天融信网络安全技术有限公司 Network card adding method, device, computing equipment and machine-readable storage medium

Similar Documents

Publication Publication Date Title
WO2021217529A1 (en) Method and system for inter-process communication
CN107690622B (en) Method, device and system for implementing hardware accelerated processing
US12061566B2 (en) IO processing method and apparatus
US7231638B2 (en) Memory sharing in a distributed data processing system using modified address space to create extended address space for copying data
CN112003797B (en) Method, system, terminal and storage medium for improving performance of virtualized DPDK network
US9621633B2 (en) Flow director-based low latency networking
JP2017504109A (en) Method and computer device for affinity binding of interrupts in a virtual network interface card
CN111586140A (en) Data interaction method and server
WO2022160714A1 (en) Communication method, apparatus, and system
CN115269213A (en) Data receiving method, data transmitting method, device, electronic device and medium
WO2023030178A1 (en) Communication method based on user-mode protocol stack, and corresponding apparatus
CN116820430B (en) Asynchronous read-write method, device, computer equipment and storage medium
CN112015515B (en) A method and device for instantiating virtual network functions
CN119135534A (en) DPDK dynamic network card adding method, storage medium, electronic device and program product
CN113535370A (en) Method and equipment for realizing multiple RDMA network card virtualization of load balancing
CN118626424A (en) Logical port management method, device, equipment and medium
CN113312137B (en) Data processing method, device, equipment and system
CN115412500A (en) Asynchronous communication method, system, medium and device supporting load balancing strategy
WO2024109005A1 (en) Execution method for serverless application, and related device
EP4411540A1 (en) Data processing method and apparatus, and computing device
CN119248462A (en) Virtual instance deployment method and system based on cloud service
CN118708368A (en) A data processing method and device for a distributed memory computing engine cluster
CN120315821A (en) A middleware management platform and working method thereof
WO2023198128A1 (en) Distributed resource sharing method and related apparatus
CN119544824A (en) A method and corresponding device for network connection hot migration

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination