



技术领域technical field
本申请涉及网卡驱动技术领域,具体而言,涉及一种虚拟设备创建方法、数据转发方法、装置及网络设备。The present application relates to the technical field of network card drivers, and in particular, to a virtual device creation method, a data forwarding method, an apparatus, and a network device.
背景技术Background technique
随着网络硬件发展的越来越快,单接口的网络吞吐越来越高,从刚开始的10Mbps,到现在的100Gbps也开始大量普及。相对于网卡硬件性能突飞猛进的发展,系统的网络处理性能逐步成为瓶颈,为了能最大效率的利用网卡的高性能,逐渐发展了硬件虚拟化技术,即把单个网络硬件设备,在多个系统中进行共享。With the faster and faster development of network hardware, the network throughput of a single interface is getting higher and higher. From the initial 10Mbps to the current 100Gbps, it has also become popular. Compared with the rapid development of network card hardware performance, the network processing performance of the system has gradually become a bottleneck. In order to utilize the high performance of network cards with maximum efficiency, hardware virtualization technology has been gradually developed, that is, a single network hardware device is implemented in multiple systems. shared.
当前对网络的虚拟化,主要是利用Intel的SR-IOV(Single Root I/OVirtualization,单根I/O虚拟化)的硬件虚拟化技术和Virtio软虚拟化技术。目前的虚拟化方式,对网络硬件设备存在各类限制,影响设备性能。例如,基于SR-IOV的虚拟化技术,对设备的BIOS(Basic Input Output System,基本输入输出系统)有限制,主要支持Intel的相关产品。PCIE(Peripheral Component Interconnect Express,高速串行计算机扩展总线标准)桥设备的BIOS需要支持Vd-t,PCIE桥设备以及桥接的所有PCIE桥也必须支持虚拟化等,且无法灵活调整设备参数。The current network virtualization mainly uses Intel's SR-IOV (Single Root I/O Virtualization, single root I/O virtualization) hardware virtualization technology and Virtio soft virtualization technology. The current virtualization methods have various restrictions on network hardware devices, which affect device performance. For example, the virtualization technology based on SR-IOV has restrictions on the BIOS (Basic Input Output System, basic input output system) of the device, and mainly supports related products of Intel. The BIOS of the PCIE (Peripheral Component Interconnect Express, high-speed serial computer expansion bus standard) bridge device needs to support Vd-t, the PCIE bridge device and all the bridged PCIE bridges must also support virtualization, etc., and the device parameters cannot be flexibly adjusted.
发明内容SUMMARY OF THE INVENTION
本申请实施例的目的在于提供一种虚拟设备创建方法、数据转发方法、装置及网络设备,能够改善在设备虚拟化过程中,对网络设备存在各类限制,影响设备性能的问题。The purpose of the embodiments of the present application is to provide a virtual device creation method, a data forwarding method, an apparatus, and a network device, which can improve the problem of various restrictions on network devices and affecting device performance during device virtualization.
为了实现上述目的,本申请的实施例通过如下方式实现:In order to achieve the above purpose, the embodiments of the present application are achieved in the following ways:
第一方面,本申请实施例提供一种虚拟设备创建方法,所述方法包括:In a first aspect, an embodiment of the present application provides a method for creating a virtual device, and the method includes:
通过预设开发工具及预设创建参数,创建表征虚拟PCIE设备的设备结构体,其中,所述设备结构体包括表示虚拟收包队列的第一队列结构体以及表示虚拟发包队列的第二队列结构体,所述预设创建参数包括欲创建的虚拟PCIE设备的预设数量、欲与所述虚拟PCIE设备关联的指定物理PCIE设备及预设队列映射关系;Create a device structure representing a virtual PCIE device by using a preset development tool and preset creation parameters, wherein the device structure includes a first queue structure representing a virtual packet receiving queue and a second queue structure representing a virtual packet sending queue body, the preset creation parameters include a preset number of virtual PCIE devices to be created, a specified physical PCIE device to be associated with the virtual PCIE device, and a preset queue mapping relationship;
将所述预设数量的所述设备结构体均与所述指定物理PCIE设备关联;Associating the preset number of the device structures with the specified physical PCIE device;
基于所述预设队列映射关系,将每个所述设备结构体中的所述第一队列结构体与所述指定物理PCIE设备中对应的物理收包队列关联,以及将每个所述设备结构体中的所述第二队列结构体与所述指定物理PCIE设备中对应的物理发包队列关联,得到所述预设数量的虚拟PCIE设备,其中,得到的每个所述虚拟PCIE设备用于通过所述虚拟收包队列接收数据,以及通过所述虚拟发包队列发送数据。Based on the preset queue mapping relationship, associate the first queue structure in each device structure with the corresponding physical packet receiving queue in the designated physical PCIE device, and associate each device structure The second queue structure in the body is associated with the corresponding physical packet sending queue in the specified physical PCIE device, to obtain the preset number of virtual PCIE devices, wherein each obtained virtual PCIE device is used for passing The virtual packet receiving queue receives data, and sends data through the virtual packet sending queue.
在上述的实施方式中,通过将预设数量的设备结构体与物理PCIE设备关联,以及将虚拟收包队列和物理收包列关联,将虚拟发包队列和物理发包队列关联,如此,一个物理PCIE设备可以创建得到多个虚拟PCIE设备,有利于物理设备的硬件资源得到充分利用,以提升处理性能,且无需依赖专门的BIOS,不需要设备支持Vd-t,提高设备虚拟化的适用范围。In the above-mentioned embodiment, by associating a preset number of device structures with physical PCIE devices, and associating the virtual packet receiving queue with the physical packet receiving queue, the virtual packet sending queue and the physical packet sending queue are associated. In this way, a physical PCIE The device can create multiple virtual PCIE devices, which is conducive to the full utilization of the hardware resources of the physical device to improve the processing performance. It does not need to rely on a special BIOS, and does not require the device to support Vd-t, which improves the application scope of device virtualization.
结合第一方面,在一些可选的实施方式中,基于所述预设队列映射关系,将每个所述设备结构体中的所述第一队列结构体与所述指定物理PCIE设备中对应的物理收包队列关联,包括:With reference to the first aspect, in some optional implementation manners, based on the preset queue mapping relationship, the first queue structure in each device structure is associated with the corresponding one in the specified physical PCIE device. Physical receive queue associations, including:
将每个所述设备结构体中的所述第一队列结构体与所述指定物理PCIE设备中相同的物理收包队列关联,以使每个所述设备结构体共享所述指定物理PCIE设备中相同的物理收包队列;Associating the first queue structure in each of the device structures with the same physical packet receiving queue in the specified physical PCIE device, so that each of the device structures shares the specified physical PCIE device The same physical receiving queue;
或者,将每个所述设备结构体中的所述第一队列结构体与所述指定物理PCIE设备中的指定物理收包队列关联,其中,不同设备结构体中的所述第一队列结构体所关联的指定物理收包队列不相同。Or, associate the first queue structure in each device structure with a specified physical packet receiving queue in the specified physical PCIE device, wherein the first queue structure in different device structures The associated specified physical receive queues are not the same.
在上述的实施方式中,虚拟PCIE设备在执行数据转发任务时,可以直接将转发任务重定向至物理PCIE设备上的收包队列或发包队列,以进行数据的转发,如此,多个虚拟PCIE设备可以共用一个物理PCIE设备的硬件资源,有利于让物理PCIE设备的硬件资源得到充分利用。In the above-mentioned embodiment, when the virtual PCIE device performs the data forwarding task, it can directly redirect the forwarding task to the packet receiving queue or the packet sending queue on the physical PCIE device for data forwarding. In this way, multiple virtual PCIE devices The hardware resources of a physical PCIE device can be shared, which is beneficial to make full use of the hardware resources of the physical PCIE device.
结合第一方面,在一些可选的实施方式中,基于所述预设队列映射关系,将每个所述设备结构体中的所述第二队列结构体与所述指定物理PCIE设备中对应的物理发包队列关联,包括:With reference to the first aspect, in some optional implementation manners, based on the preset queue mapping relationship, the second queue structure in each of the device structures is associated with the corresponding one in the specified physical PCIE device. Physical packet sending queue association, including:
将每个所述设备结构体中的所述第二队列结构体与所述指定物理PCIE设备中相同的物理发包队列关联,以使每个所述设备结构体共享所述指定物理PCIE设备中相同的物理发包队列;Associating the second queue structure in each of the device structures with the same physical packet sending queue in the specified physical PCIE device, so that each of the device structures shares the same in the specified physical PCIE device The physical packet sending queue;
或者,将每个所述设备结构体中的所述第二队列结构体与所述指定物理PCIE设备中的指定物理发包队列关联,其中,不同设备结构体中的所述第二队列结构体所关联的指定物理发包队列不相同。Or, associate the second queue structure in each of the device structures with a specified physical packet sending queue in the specified physical PCIE device, wherein the second queue structures in different device structures are The associated specified physical sending queues are not the same.
结合第一方面,在一些可选的实施方式中,在创建表征虚拟PCIE设备的设备结构体之后,所述方法还包括:With reference to the first aspect, in some optional implementation manners, after creating a device structure representing a virtual PCIE device, the method further includes:
将创建的所述预设数量的所述设备结构体,添加于全局链表中,其中,所述全局链表中预先添加有当前网络中的所有物理PCIE设备,在所述全局链表中,每个所述设备结构体包括身份标识及表征虚拟PCIE设备的标识。The preset number of the created device structures is added to a global linked list, wherein all physical PCIE devices in the current network are pre-added in the global linked list, and in the global linked list, each The device structure includes an identity identifier and an identifier representing the virtual PCIE device.
结合第一方面,在一些可选的实施方式中,所述方法包括:In conjunction with the first aspect, in some optional embodiments, the method includes:
从所述全局链表中选择用于执行数据转发业务的当前PCIE设备;Select the current PCIE device for performing the data forwarding service from the global linked list;
当所述当前PCIE设备为虚拟PCIE设备时,将所述数据转发业务对应的待转发数据,重定向至目标物理PCIE设备中的目标物理收包队列,以接收所述待转发数据,和/或When the current PCIE device is a virtual PCIE device, redirect the data to be forwarded corresponding to the data forwarding service to the target physical packet receiving queue in the target physical PCIE device to receive the to-be-forwarded data, and/or
重定向至所述目标物理PCIE设备中的目标物理发包队列,以发送所述待转发数据,其中,所述目标物理PCIE设备为与所述当前PCIE设备关联的物理PCIE设备,所述目标物理收包队列为所述目标物理PCIE设备中的与所述当前PCIE设备中的虚拟收包队列对应的物理发包队列,所述目标物理发包队列为所述目标物理PCIE设备中的与所述当前PCIE设备中的虚拟发包队列对应的物理发包队列。Redirecting to the target physical packet sending queue in the target physical PCIE device to send the data to be forwarded, wherein the target physical PCIE device is a physical PCIE device associated with the current PCIE device, and the target physical receiving The packet queue is the physical packet sending queue in the target physical PCIE device corresponding to the virtual packet receiving queue in the current PCIE device, and the target physical packet sending queue is the target physical PCIE device and the current PCIE device. The physical packet sending queue corresponding to the virtual packet sending queue in .
第二方面,本申请还提供一种数据转发方法,所述方法包括:In a second aspect, the present application also provides a data forwarding method, the method comprising:
从全局链表中选择用于执行数据转发业务的当前PCIE设备,其中,所述全局链表中预先添加有多个PCIE设备;Select the current PCIE device for performing the data forwarding service from the global linked list, wherein a plurality of PCIE devices are pre-added in the global linked list;
当所述当前PCIE设备为虚拟PCIE设备时,将所述数据转发业务对应的待转发数据,重定向至目标物理PCIE设备中的目标物理收包队列,以接收所述待转发数据,和/或When the current PCIE device is a virtual PCIE device, redirect the data to be forwarded corresponding to the data forwarding service to the target physical packet receiving queue in the target physical PCIE device to receive the to-be-forwarded data, and/or
重定向至所述目标物理PCIE设备中的目标物理发包队列,以发送所述待转发数据,其中,所述目标物理PCIE设备为与所述当前PCIE设备关联的物理PCIE设备,所述目标物理收包队列为所述目标物理PCIE设备中的与所述当前PCIE设备中的虚拟收包队列对应的物理发包队列,所述目标物理发包队列为所述目标物理PCIE设备中的与所述当前PCIE设备中的虚拟发包队列对应的物理发包队列。Redirecting to the target physical packet sending queue in the target physical PCIE device to send the data to be forwarded, wherein the target physical PCIE device is a physical PCIE device associated with the current PCIE device, and the target physical receiving The packet queue is the physical packet sending queue in the target physical PCIE device corresponding to the virtual packet receiving queue in the current PCIE device, and the target physical packet sending queue is the target physical PCIE device and the current PCIE device. The physical packet sending queue corresponding to the virtual packet sending queue in .
第三方面,本申请还提供一种虚拟设备创建装置,所述装置包括:In a third aspect, the present application further provides an apparatus for creating a virtual device, the apparatus comprising:
创建单元,用于通过预设开发工具及预设创建参数,创建表征虚拟PCIE设备的设备结构体,其中,所述设备结构体包括表示虚拟收包队列的第一队列结构体以及表示虚拟发包队列的第二队列结构体,所述预设创建参数包括欲创建的虚拟PCIE设备的预设数量、欲与所述虚拟PCIE设备关联的指定物理PCIE设备及预设队列映射关系;The creation unit is configured to create a device structure representing a virtual PCIE device by using a preset development tool and preset creation parameters, wherein the device structure includes a first queue structure representing a virtual packet receiving queue and a virtual packet sending queue. The second queue structure, the preset creation parameters include a preset number of virtual PCIE devices to be created, a specified physical PCIE device to be associated with the virtual PCIE device, and a preset queue mapping relationship;
第一关联单元,用于将所述预设数量的所述设备结构体均与所述指定物理PCIE设备关联;a first association unit, configured to associate the preset number of the device structures with the specified physical PCIE device;
第二关联单元,用于基于所述预设队列映射关系,将每个所述设备结构体中的所述第一队列结构体与所述指定物理PCIE设备中对应的物理收包队列关联,以及将每个所述设备结构体中的所述第二队列结构体与所述指定物理PCIE设备中对应的物理发包队列关联,得到所述预设数量的虚拟PCIE设备,其中,得到的每个所述虚拟PCIE设备用于通过所述虚拟收包队列接收数据,以及通过所述虚拟发包队列发送数据。a second association unit, configured to associate the first queue structure in each of the device structures with the corresponding physical packet receiving queue in the specified physical PCIE device based on the preset queue mapping relationship, and Associating the second queue structure in each of the device structures with the corresponding physical packet sending queues in the specified physical PCIE device to obtain the preset number of virtual PCIE devices, wherein each obtained The virtual PCIE device is configured to receive data through the virtual packet receiving queue, and send data through the virtual packet sending queue.
第四方面,本申请还提供一种数据转发装置,所述装置包括:In a fourth aspect, the present application further provides a data forwarding device, the device comprising:
调度单元,用于从全局链表中选择用于执行数据转发业务的当前PCIE设备,其中,所述全局链表中预先添加有多个PCIE设备;a scheduling unit, configured to select a current PCIE device for performing a data forwarding service from a global linked list, wherein a plurality of PCIE devices are pre-added in the global linked list;
重定向单元,用于当所述当前PCIE设备为虚拟PCIE设备时,将所述数据转发业务对应的待转发数据,重定向至目标物理PCIE设备中的目标物理收包队列,以接收所述待转发数据,和/或A redirection unit, configured to redirect the data to be forwarded corresponding to the data forwarding service to the target physical packet receiving queue in the target physical PCIE device when the current PCIE device is a virtual PCIE device, to receive the to-be-forwarded data forwarding data, and/or
重定向至所述目标物理PCIE设备中的目标物理发包队列,以发送所述待转发数据,其中,所述目标物理PCIE设备为与所述当前PCIE设备关联的物理PCIE设备,所述目标物理收包队列为所述目标物理PCIE设备中的与所述当前PCIE设备中的虚拟收包队列对应的物理发包队列,所述目标物理发包队列为所述目标物理PCIE设备中的与所述当前PCIE设备中的虚拟发包队列对应的物理发包队列。Redirecting to the target physical packet sending queue in the target physical PCIE device to send the data to be forwarded, wherein the target physical PCIE device is a physical PCIE device associated with the current PCIE device, and the target physical receiving The packet queue is the physical packet sending queue in the target physical PCIE device corresponding to the virtual packet receiving queue in the current PCIE device, and the target physical packet sending queue is the target physical PCIE device and the current PCIE device. The physical packet sending queue corresponding to the virtual packet sending queue in .
第五方面,本申请还提供一种网络设备,所述网络设备包括相互耦合的处理器及存储器,所述存储器内存储计算机程序,当所述计算机程序被所述处理器执行时,使得所述网络设备执行上述的虚拟设备创建方法,或上述的数据转发方法。In a fifth aspect, the present application further provides a network device, the network device includes a mutually coupled processor and a memory, the memory stores a computer program, and when the computer program is executed by the processor, the The network device executes the above-mentioned virtual device creation method or the above-mentioned data forwarding method.
第六方面,本申请还提供一种计算机可读存储介质,所述计算机可读存储介质中存储有计算机程序,当所述计算机程序在计算机上运行时,使得所述计算机执行上述的虚拟设备创建方法,或上述的数据转发方法。In a sixth aspect, the present application further provides a computer-readable storage medium, where a computer program is stored in the computer-readable storage medium, and when the computer program runs on a computer, the computer is made to execute the above-mentioned virtual device creation method, or the above-mentioned data forwarding method.
附图说明Description of drawings
为了更清楚地说明本申请实施例的技术方案,下面将对本申请实施例中所需要使用的附图作简单地介绍,应当理解,以下附图仅示出了本申请的某些实施例,因此不应被看作是对范围的限定,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他相关的附图。In order to explain the technical solutions of the embodiments of the present application more clearly, the following briefly introduces the accompanying drawings that need to be used in the embodiments of the present application. It should be understood that the following drawings only show some embodiments of the present application, therefore It should not be regarded as a limitation of the scope. For those of ordinary skill in the art, other related drawings can also be obtained from these drawings without any creative effort.
图1为本申请实施例提供的网络设备的结构示意图。FIG. 1 is a schematic structural diagram of a network device according to an embodiment of the present application.
图2为本申请实施例提供的虚拟设备创建方法的流程示意图。FIG. 2 is a schematic flowchart of a method for creating a virtual device provided by an embodiment of the present application.
图3为本申请实施例提供的虚拟设备创建装置的框图。FIG. 3 is a block diagram of an apparatus for creating a virtual device provided by an embodiment of the present application.
图4为本申请实施例提供的数据转发装置的框图。FIG. 4 is a block diagram of a data forwarding apparatus provided by an embodiment of the present application.
图标:10-网络设备;11-处理模块;12-存储模块;13-通信模块;200-虚拟设备创建装置;210-创建单元;220-第一关联单元;230-第二关联单元;400-数据转发装置;410-调度单元;420-重定向单元。Icons: 10-network equipment; 11-processing module; 12-storage module; 13-communication module; 200-virtual device creation device; 210-creation unit; 220-first association unit; 230-second association unit; 400- A data forwarding device; 410 - a scheduling unit; 420 - a redirection unit.
具体实施方式Detailed ways
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行描述。需要说明的是,术语“第一”、“第二”等仅用于区分描述,而不能理解为指示或暗示相对重要性。在不冲突的情况下,下述的实施例及实施例中的特征可以相互组合。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. It should be noted that the terms "first", "second" and the like are only used for distinguishing descriptions, and cannot be understood as indicating or implying relative importance. The embodiments described below and features in the embodiments may be combined with each other without conflict.
第一实施例first embodiment
请参照图1,本申请提供一种网络设备10,网络设备10可以包括处理模块11及存储模块12。存储模块12内存储计算机程序,当计算机程序被所述处理模块11执行时,使得网络设备10能够执行下述虚拟设备创建方法、数据转发方法中的各步骤。Referring to FIG. 1 , the present application provides a
可以理解的是,图1所示的结构仅为网络设备10的一种结构示意图,网络设备10还可以包括比图1所示更多的组件。图1中所示的各组件可以采用硬件、软件或其组合实现。例如,网络设备10还可以包括通信模块13,用于建立与其他设备的通信连接。It can be understood that the structure shown in FIG. 1 is only a schematic structural diagram of the
在本实施例中,网络设备10可以为一种PCIE(Peripheral ComponentInterconnect Express,高速串行计算机扩展总线标准)设备,或者为用于对PCIE设备进行管理控制的设备。其中,一个物理PCIE设备可以作为一个物理网卡使用,用于转发数据。In this embodiment, the
在本实施例中,当一个物理PCIE设备可以通过虚拟化处理,形成多个虚拟PCIE设备,从而可以作为多个虚拟的物理网卡以转发数据。In this embodiment, when a physical PCIE device can be processed by virtualization, multiple virtual PCIE devices are formed, so that it can be used as multiple virtual physical network cards to forward data.
请参照图2,本申请的还提供一种虚拟设备创建方法,可以应用于上述的网络设备10中,由网络设备10执行或实现方法中的各步骤。方法可以包括如下步骤:Referring to FIG. 2 , the present application further provides a method for creating a virtual device, which can be applied to the above-mentioned
步骤S110,通过预设开发工具及预设创建参数,创建表征虚拟PCIE设备的设备结构体,其中,所述设备结构体包括表示虚拟收包队列的第一队列结构体以及表示虚拟发包队列的第二队列结构体,所述预设创建参数包括欲创建的虚拟PCIE设备的预设数量、欲与所述虚拟PCIE设备关联的指定物理PCIE设备及预设队列映射关系;Step S110, creating a device structure representing a virtual PCIE device by using a preset development tool and preset creation parameters, wherein the device structure includes a first queue structure representing a virtual packet receiving queue and a second queue representing the virtual packet sending queue. Two queue structures, the preset creation parameters include a preset number of virtual PCIE devices to be created, a specified physical PCIE device to be associated with the virtual PCIE device, and a preset queue mapping relationship;
步骤S120,将所述预设数量的所述设备结构体均与所述指定物理PCIE设备关联;Step S120, associating the preset number of the device structures with the designated physical PCIE device;
步骤S130,基于所述预设队列映射关系,将每个所述设备结构体中的所述第一队列结构体与所述指定物理PCIE设备中对应的物理收包队列关联,以及将每个所述设备结构体中的所述第二队列结构体与所述指定物理PCIE设备中对应的物理发包队列关联,得到所述预设数量的虚拟PCIE设备,其中,得到的每个所述虚拟PCIE设备用于通过所述虚拟收包队列接收数据,以及通过所述虚拟发包队列发送数据。Step S130, based on the preset queue mapping relationship, associate the first queue structure in each of the device structures with the corresponding physical packet receiving queue in the specified physical PCIE device, and associate each The second queue structure in the device structure is associated with the corresponding physical packet sending queue in the specified physical PCIE device, to obtain the preset number of virtual PCIE devices, wherein each of the obtained virtual PCIE devices for receiving data through the virtual packet receiving queue and sending data through the virtual packet sending queue.
在上述的实施方式中,通过将预设数量的设备结构体与物理PCIE设备关联,以及将虚拟收包队列和物理收包列关联,将虚拟发包队列和物理发包队列关联,如此,一个物理PCIE设备可以创建得到多个虚拟PCIE设备,有利于物理设备的硬件资源得到充分利用,以提升处理性能,且无需依赖专门的BIOS,不需要设备支持Vd-t,提高设备虚拟化的适用范围。In the above-mentioned embodiment, by associating a preset number of device structures with physical PCIE devices, and associating the virtual packet receiving queue with the physical packet receiving queue, the virtual packet sending queue and the physical packet sending queue are associated. In this way, a physical PCIE The device can create multiple virtual PCIE devices, which is conducive to the full utilization of the hardware resources of the physical device to improve the processing performance. It does not need to rely on a special BIOS, and does not require the device to support Vd-t, which improves the application scope of device virtualization.
下面将对方法中的各步骤进行详细阐述,如下:Each step in the method will be described in detail below:
在步骤S110中,预设开发工具可以根据实际情况灵活确定,例如,预设开发工具可以为DPDK(Data Plane Development Kit,数据平面开发工具)。In step S110, the preset development tool may be flexibly determined according to the actual situation, for example, the preset development tool may be DPDK (Data Plane Development Kit, data plane development tool).
预设创建参数可以包括但不限于欲创建的虚拟PCIE设备的预设数量、欲进行虚拟化的物理PCIE设备、预设队列映射关系等。The preset creation parameters may include, but are not limited to, a preset number of virtual PCIE devices to be created, physical PCIE devices to be virtualized, a preset queue mapping relationship, and the like.
可理解地,预设数量、欲进行虚拟化的物理PCIE设备可以根据实际情况灵活确定。另外,预设队列映射关系指虚拟PCIE设备中的虚拟队列与物理PCIE设备中的物理队列的映射关系,可以根据实际情况灵活确定。Understandably, the preset number of physical PCIE devices to be virtualized can be flexibly determined according to actual conditions. In addition, the preset queue mapping relationship refers to the mapping relationship between the virtual queue in the virtual PCIE device and the physical queue in the physical PCIE device, and can be flexibly determined according to the actual situation.
在本实施例中,一个设备结构体可理解为与一个物理PCIE设备对应的结构体,可以用于表示一个虚拟PCIE设备。第一队列结构体用于表示虚拟收包队列,用于接收数据。第二队列结构体用于表示虚拟发包队列,用于发送数据。In this embodiment, a device structure may be understood as a structure corresponding to a physical PCIE device, and may be used to represent a virtual PCIE device. The first queue structure is used to represent a virtual packet receiving queue for receiving data. The second queue structure is used to represent a virtual packet sending queue for sending data.
通常而言,一个物理PCIE设备上,具有多个物理收包队列及多个物理收包队列。所创建的虚拟PCIE设备中的虚拟收包队列可以小于或等于物理PCIE设备上的物理收包队列;虚拟PCIE设备中的虚拟发包队列可以小于或等于物理PCIE设备上的物理发包队列。即,预设创建参数还可以包括欲创建的虚拟PCIE设备中的虚拟收包队列和虚拟发包队列的数量。Generally speaking, a physical PCIE device has multiple physical packet receiving queues and multiple physical packet receiving queues. The virtual packet receiving queue in the created virtual PCIE device may be less than or equal to the physical packet receiving queue on the physical PCIE device; the virtual packet sending queue in the virtual PCIE device may be less than or equal to the physical packet sending queue on the physical PCIE device. That is, the preset creation parameters may further include the number of virtual packet receiving queues and virtual packet sending queues in the virtual PCIE device to be created.
在步骤S110之前,网络设备10可以查找当前网络中的所有PCIE设备,并逐个添加进链表,以作为全局链表。在后续创建了虚拟PCIE设备后,再将所创建的虚拟PCIE设备加入该全局链表。在执行数据转发业务时,可以从全局链表中,调度相应的PCIE设备进行数据的转发。Before step S110, the
在步骤S110中,网络设备10上可以部署有DPDK工具,用户可以将预设创建参数输入DPDK工具中,由DPDK进行初始化,便可以创建虚拟PCIE设备的设备结构体。In step S110, a DPDK tool may be deployed on the
在步骤S120中,指定物理PCIE设备可以根据实际情况灵活确定。即,用户可以根据实际情况灵活选择用于与预设数量的设备结构体所关联的物理PCIE设备。In step S120, the designated physical PCIE device may be flexibly determined according to the actual situation. That is, the user can flexibly select the physical PCIE devices associated with the preset number of device structures according to the actual situation.
可理解地,与一个物理PCIE设备所关联的所有设备结构体,均可以使用该物理PCIE设备的硬件资源,比如,硬件资源包括物理收包队列、物理发包队列等。如此,可以对一个物理PCIE设备进行虚拟化处理,得到多个虚拟PCIE设备。Understandably, all device structures associated with a physical PCIE device can use the hardware resources of the physical PCIE device, for example, the hardware resources include a physical packet receiving queue, a physical packet sending queue, and the like. In this way, one physical PCIE device can be virtualized to obtain multiple virtual PCIE devices.
在步骤S130中,预设队列映射关系可以根据实际情况灵活设置。例如,当需要针对一个物理PCIE设备,创建多个虚拟PCIE设备时,多个虚拟PCIE设备以共享该物理PCIE设备的所有队列(指收包队列及发包队列);或者,每个虚拟PCIE设备可以独占物理PCIE设备中的相应队列,即,不同虚拟PCIE设备在物理PCIE设备中占用的队列不相同。In step S130, the preset queue mapping relationship can be flexibly set according to the actual situation. For example, when multiple virtual PCIE devices need to be created for a physical PCIE device, the multiple virtual PCIE devices share all queues (referring to the packet receiving queue and the packet sending queue) of the physical PCIE device; or, each virtual PCIE device can The corresponding queues in the physical PCIE devices are exclusively occupied, that is, the queues occupied by different virtual PCIE devices in the physical PCIE devices are different.
例如,在步骤S130中,基于所述预设队列映射关系,将每个所述设备结构体中的所述第一队列结构体与所述指定物理PCIE设备中对应的物理收包队列关联,可以包括:For example, in step S130, based on the preset queue mapping relationship, the first queue structure in each of the device structures is associated with the corresponding physical packet receiving queue in the specified physical PCIE device. include:
将每个所述设备结构体中的所述第一队列结构体与所述指定物理PCIE设备中相同的物理收包队列关联,以使每个所述设备结构体共享所述指定物理PCIE设备中相同的物理收包队列;Associating the first queue structure in each of the device structures with the same physical packet receiving queue in the specified physical PCIE device, so that each of the device structures shares the specified physical PCIE device The same physical receiving queue;
或者,将每个所述设备结构体中的所述第一队列结构体与所述指定物理PCIE设备中的指定物理收包队列关联,其中,不同设备结构体中的所述第一队列结构体所关联的指定物理收包队列不相同。Or, associate the first queue structure in each device structure with a specified physical packet receiving queue in the specified physical PCIE device, wherein the first queue structure in different device structures The associated specified physical receive queues are not the same.
示例性地,假设在指定物理PCIE设备中,具有5个收包队列,且欲创建2个虚拟PCIE设备,即,2个设备结构体。在对设备结构体的队列结构体与物理队列进行关联时,可以是将2个设备结构体的第一队列结构体均与5个收包队列队列关联,以共享相同的物理收包队列。Exemplarily, it is assumed that there are 5 packet receiving queues in the designated physical PCIE device, and 2 virtual PCIE devices, ie, 2 device structures, are to be created. When associating the queue structures of the device structures with the physical queues, the first queue structures of the two device structures may be associated with five packet receiving queues, so as to share the same physical packet receiving queue.
或者,将一个设备结构体的第一队列结构体与5个收包队列队中的1个或2个收包队列关联;以及将另一个设备结构体的第一队列结构体与5个收包队列队中剩余收包队列关联,或与剩余收包队列中的1个或2个收包队列关联,其中,剩余收包队列至未被关联的收包队列。如此,每个设备结构体可以独占指定物理PCIE设备中的收包队列,无需共享收包队列。Or, associate the first queue structure of one device structure with 1 or 2 of the 5 receiving queues; and associate the first queue structure of another device structure with 5 receiving queues The remaining packet receiving queues in the queue queue are associated, or are associated with one or two packet receiving queues in the remaining packet receiving queues, wherein the remaining packet receiving queues are to the unassociated packet receiving queues. In this way, each device structure can exclusively occupy the packet receiving queue in the specified physical PCIE device, and there is no need to share the packet receiving queue.
在步骤S130中,基于所述预设队列映射关系,将每个所述设备结构体中的所述第二队列结构体与所述指定物理PCIE设备中对应的物理发包队列关联,包括:In step S130, based on the preset queue mapping relationship, associating the second queue structure in each device structure with the corresponding physical packet sending queue in the specified physical PCIE device, including:
将每个所述设备结构体中的所述第二队列结构体与所述指定物理PCIE设备中相同的物理发包队列关联,以使每个所述设备结构体共享所述指定物理PCIE设备中相同的物理发包队列;Associating the second queue structure in each of the device structures with the same physical packet sending queue in the specified physical PCIE device, so that each of the device structures shares the same in the specified physical PCIE device The physical packet sending queue;
或者,将每个所述设备结构体中的所述第二队列结构体与所述指定物理PCIE设备中的指定物理发包队列关联,其中,不同设备结构体中的所述第二队列结构体所关联的指定物理发包队列不相同。Or, associate the second queue structure in each of the device structures with a specified physical packet sending queue in the specified physical PCIE device, wherein the second queue structures in different device structures are The associated specified physical sending queues are not the same.
示例性地,假设在指定物理PCIE设备中,具有5个发包队列,且欲创建2个虚拟PCIE设备,即,2个设备结构体。在对设备结构体的队列结构体与物理队列进行关联时,可以是将2个设备结构体的第二队列结构体均与5个发包队列队列关联,以共享相同的物理发包队列。Exemplarily, it is assumed that there are 5 packet sending queues in a designated physical PCIE device, and 2 virtual PCIE devices, that is, 2 device structures, are to be created. When associating the queue structures of the device structures with the physical queues, the second queue structures of the two device structures may be associated with five packet sending queues, so as to share the same physical packet sending queue.
或者,将一个设备结构体的第一队列结构体与5个发包队列队中的1个或2个发包队列关联;以及将另一个设备结构体的第一队列结构体与5个发包队列队中剩余发包队列关联,或与剩余发包队列中的1个或2个发包队列关联,其中,剩余发包队列至未被关联的发包队列。如此,每个设备结构体可以独占指定物理PCIE设备中的发包队列,无需共享发包队列。Or, associate the first queue structure of a device structure with 1 or 2 of the 5 packet sending queues; and associate the first queue structure of another device structure with the 5 packet sending queues The remaining packet sending queues are associated, or are associated with one or two packet sending queues in the remaining packet sending queues, wherein the remaining packet sending queues are to the unassociated packet sending queues. In this way, each device structure can exclusively occupy the packet sending queue in the specified physical PCIE device, without sharing the packet sending queue.
在步骤S110之后,方法还可以包括:将创建的所述预设数量的所述设备结构体,添加于全局链表中,其中,所述全局链表中预先添加有当前网络中的所有物理PCIE设备,在所述全局链表中,每个所述设备结构体包括身份标识及表征虚拟PCIE设备的标识。After step S110, the method may further include: adding the created preset number of the device structures to a global linked list, wherein all physical PCIE devices in the current network are pre-added to the global linked list, In the global linked list, each of the device structures includes an identity identifier and an identifier representing a virtual PCIE device.
可理解地,通过将所创建的设备结构体加入全局链表中,方便将设备结构体作为虚拟PCIE设备进行调用,以执行相应的数据转发业务。Understandably, by adding the created device structure to the global linked list, it is convenient to call the device structure as a virtual PCIE device to execute the corresponding data forwarding service.
在步骤S130之后,方法还可以包利用所创建的虚拟PCIE设备执行数据转发业务的步骤。例如,方法还可以包括:After step S130, the method may further include the step of using the created virtual PCIE device to perform a data forwarding service. For example, the method may also include:
从所述全局链表中选择用于执行数据转发业务的当前PCIE设备;Select the current PCIE device for performing the data forwarding service from the global linked list;
当所述当前PCIE设备为虚拟PCIE设备时,将所述数据转发业务对应的待转发数据,重定向至目标物理PCIE设备中的目标物理收包队列,以接收所述待转发数据,和/或重定向至所述目标物理PCIE设备中的目标物理发包队列,以发送所述待转发数据,其中,所述目标物理PCIE设备为与所述当前PCIE设备关联的物理PCIE设备,所述目标物理收包队列为所述目标物理PCIE设备中的与所述当前PCIE设备中的虚拟收包队列对应的物理发包队列,所述目标物理发包队列为所述目标物理PCIE设备中的与所述当前PCIE设备中的虚拟发包队列对应的物理发包队列。When the current PCIE device is a virtual PCIE device, redirect the data to be forwarded corresponding to the data forwarding service to the target physical packet receiving queue in the target physical PCIE device to receive the to-be-forwarded data, and/or Redirecting to the target physical packet sending queue in the target physical PCIE device to send the data to be forwarded, wherein the target physical PCIE device is a physical PCIE device associated with the current PCIE device, and the target physical receiving The packet queue is the physical packet sending queue in the target physical PCIE device corresponding to the virtual packet receiving queue in the current PCIE device, and the target physical packet sending queue is the target physical PCIE device and the current PCIE device. The physical packet sending queue corresponding to the virtual packet sending queue in .
在本实施例中,虚拟PCIE设备在执行数据转发任务时,可以基于转发任务对应的目的地址,从全局链表中选择相应的PCIE设备。在全局链表中,各PCIE设备具有相应的类型标识,用于表征是虚拟设备,或物理设备。若所选择的PCIE设备为虚拟PCIE设备,则可以直接将转发任务重定向至物理PCIE设备上的收包队列或发包队列,以进行数据的转发,如此,多个虚拟PCIE设备可以共用一个物理PCIE设备的硬件资源,有利于让物理PCIE设备的硬件资源得到充分利用。In this embodiment, when the virtual PCIE device performs the data forwarding task, the corresponding PCIE device may be selected from the global linked list based on the destination address corresponding to the forwarding task. In the global linked list, each PCIE device has a corresponding type identifier, which is used to represent a virtual device or a physical device. If the selected PCIE device is a virtual PCIE device, the forwarding task can be directly redirected to the packet receiving queue or the packet sending queue on the physical PCIE device for data forwarding. In this way, multiple virtual PCIE devices can share one physical PCIE device. The hardware resources of the device are beneficial to make full use of the hardware resources of the physical PCIE device.
为了便于理解方法的实现过程,下面进行举例阐述,如下:In order to facilitate the understanding of the implementation process of the method, an example is described below, as follows:
在DPDK工具中,表示虚拟PCIE设备的结构体为struct rte_pci_device;增加变量vdev以及index两个标记,vdev用于标识是该设备是否是虚拟设备,index标识该虚拟设备的索引号。例如,vdev的值为1,表示该设备为虚拟PCIE设备,若vdev的值为0,则表示该设备为物理PCIE设备。另外,index作为虚拟PCIE设备的编号,可以根据实际情况设置,例如,当创建了多个虚拟PCIE设备时,每个虚拟设备可以从0开始编号,以便于进行索引或区分。In the DPDK tool, the structure representing the virtual PCIE device is struct rte_pci_device; two variables, vdev and index, are added. Vdev is used to identify whether the device is a virtual device, and index identifies the index number of the virtual device. For example, if the value of vdev is 1, it indicates that the device is a virtual PCIE device, and if the value of vdev is 0, it indicates that the device is a physical PCIE device. In addition, the index, as the number of the virtual PCIE device, can be set according to the actual situation. For example, when multiple virtual PCIE devices are created, each virtual device can be numbered from 0 to facilitate indexing or differentiation.
在DPDK工具中,可以创建表示虚拟收包队列的结构体struct rx_queue,增加poll_ring和rx_real两个变量,其中poll_ring为struct rte_mempool结构体。rx_real为struct rx_queue型指针,用于建立虚拟收包队列与物理PCIE设备中的收包队列的对应关系,以便于重定向。In the DPDK tool, you can create a structure struct rx_queue representing the virtual receiving queue, and add two variables, poll_ring and rx_real, where poll_ring is a struct rte_mempool structure. rx_real is a struct rx_queue type pointer, which is used to establish the corresponding relationship between the virtual packet receiving queue and the packet receiving queue in the physical PCIE device, so as to facilitate redirection.
在DPDK工具中,可以创建表示虚拟发包队列的结构体struct tx_queue,增加tx_real变量。tx_real为struct tx_queue型指针,用于建立虚拟发包队列与物理PCIE设备中的发包队列的对应关系,以便于重定向。In the DPDK tool, you can create a structure struct tx_queue representing the virtual packet sending queue, and increase the tx_real variable. tx_real is a struct tx_queue type pointer, which is used to establish the corresponding relationship between the virtual packet sending queue and the packet sending queue in the physical PCIE device, so as to facilitate redirection.
在创建虚拟PCIE设备时,网络设备10先查找当前网络中的所有物理PCIE设备,并逐个添加进链表。然后,针对需要虚拟化处理的物理PCIE设备,输入上述的预设创建参数(例如,欲创建的虚拟PCIE设备的预设数量及预设队列映射关系等),创建表示虚拟PCIE设备的设备结构体。然后,将虚拟出来的PCIE设备的设备结构体逐个添加进全局链表,并置vdev为1,index从0递增。其中,在全局链表中,物理PCIE设备的vdev为0。When creating a virtual PCIE device, the
然后,遍历全局链表,初始化链表中的各个PCIE设备。例如,若PCIE设备的vdev为0,则以物理PCIE设备的初始化方式,进行初始化操作,包括:Then, the global linked list is traversed, and each PCIE device in the linked list is initialized. For example, if the vdev of the PCIE device is 0, the initialization operation is performed in the initialization mode of the physical PCIE device, including:
A、物理PCIE设备的初始化方式,指对设备的硬件进行初始化,为本领域技术人员熟知的初始化方式,这里不再赘述。A. The initialization mode of the physical PCIE device refers to initializing the hardware of the device, which is an initialization mode well known to those skilled in the art, and will not be repeated here.
B、若PCIE设备的vdev为1,且index为0的,则初始化方式与物理PCIE设备的初始化方式相同。B. If the vdev of the PCIE device is 1 and the index is 0, the initialization method is the same as that of the physical PCIE device.
C、若PCIE设备的vdev为1,且index不为0,则跳过设备初始化,遍历全局变量,找到vdev为1且index为0的初始化数据结构,并进行复制,然后使用所复制的初始化数据结构即可。C. If the vdev of the PCIE device is 1 and the index is not 0, skip the device initialization, traverse the global variables, find the initialization data structure with vdev 1 and index 0, copy it, and then use the copied initialization data structure.
然后,网卡驱动初始化PCIE对应的网卡功能,初始化队列,包括:Then, the network card driver initializes the network card function corresponding to PCIE, and initializes the queue, including:
A、对于vdev为0的PCIE设备,以物理PCIE设备中的队列初始化方式进行初始化,该初始化方式为本领域技术人员熟知这里不再赘述。A. For the PCIE device whose vdev is 0, the initialization is performed in the queue initialization mode in the physical PCIE device, and the initialization mode is well known to those skilled in the art and will not be repeated here.
B、对于vdev为1的设备,根据传入的预设队列映射关系,有2种方式进行初始化:B. For a device whose vdev is 1, there are two ways to initialize it according to the incoming preset queue mapping relationship:
i.一种是全部虚拟PCIE设备共享物理PCIE设备的队列;i. One is that all virtual PCIE devices share the queue of physical PCIE devices;
ii.另外一种是每个虚拟PCIE设备按需分配指定物理PCIE中的队列数,每个虚拟PCIE设备独占分配到的队列,其中,针对与该指定物理PCIE设备对应的所有虚拟PCIE设备,各虚拟PCIE设备分配到的队列的总数不超过指定物理设备的队列总数;ii. The other is that each virtual PCIE device allocates the number of queues in the specified physical PCIE as needed, and each virtual PCIE device exclusively allocates the queues to which it is assigned, wherein, for all virtual PCIE devices corresponding to the specified physical PCIE device, each The total number of queues allocated to the virtual PCIE device does not exceed the total number of queues of the specified physical device;
其中,对于全部虚拟设备共享物理PCIE设备的队列的情况,每个虚拟PCIE设备的队列索引和tx_real(rx_real)一一对应。Wherein, in the case where all virtual devices share the queue of the physical PCIE device, the queue index of each virtual PCIE device is in one-to-one correspondence with tx_real (rx_real).
对于独占的队列,网络设备10逐个进行初始化,每一个虚拟队列的索引,指向实际的物理队列,即每个虚拟队列的tx_real(rx_real)不一样。For exclusive queues, the
PCIE设备的CPU从队列进行报文收发。其中,报文的转发方式可以如下:The CPU of the PCIE device sends and receives packets from the queue. The packet forwarding method can be as follows:
对于vdev为1的PICE设备设备,并且是共享物理队列的情况,所有针对虚拟设备的轮询,最终会重定向到对应的物理设备的物理队列上,然后会根据报文目的MAC进行匹配,分别进入对应的虚拟设备的队列,其中,可以通过串行或对物理队列进行上锁的方式,避免队列冲突;For a PICE device with vdev of 1 and a shared physical queue, all polling for virtual devices will eventually be redirected to the physical queue of the corresponding physical device, and then matched according to the destination MAC of the message, respectively. Enter the queue of the corresponding virtual device, in which the queue conflict can be avoided by serializing or locking the physical queue;
对于独占队列的情况,则直接将报文重定向至相应的物理队列,然后对报文收发。In the case of an exclusive queue, the packet is directly redirected to the corresponding physical queue, and then the packet is sent and received.
基于上述设计,上层队列和PICE设备绑定代码不需要改变,因为看到的所有备都是物理设备。另外,能极大降低硬件成本,不需要专门BIOS支持,也不需要PCIE设备支持Vd-t,并且PCIE设备的系统可以是但不限于X86、ARM还是MIPS等,只要是PCIE标准设备即可。另外,该设备虚拟化处理,不会增加应用开发成本,所有虚拟化相关操作在驱动层,对上层应用完全透明,应用层可以保持不变。Based on the above design, the upper-layer queue and PICE device binding code do not need to be changed, because all devices seen are physical devices. In addition, the hardware cost can be greatly reduced, no special BIOS support is required, and no PCIE device supports Vd-t, and the system of the PCIE device can be but not limited to X86, ARM, or MIPS, as long as it is a PCIE standard device. In addition, the device is virtualized, which will not increase the cost of application development. All virtualization-related operations are performed at the driver layer, which is completely transparent to the upper-layer application, and the application layer can remain unchanged.
请参照图3,本申请实施例还提供一种虚拟设备创建装置200,可以应用于上述的网络设备10中,用于执行方法中的各步骤。虚拟设备创建装置200包括至少一个可以软件或固件(Firmware)的形式存储于存储模块12中或固化在网络设备10操作系统(OperatingSystem,OS)中的软件功能模块。处理模块11用于执行存储模块12中存储的可执行模块,例如虚拟设备创建装置200所包括的软件功能模块及计算机程序等。Referring to FIG. 3 , an embodiment of the present application further provides an
虚拟设备创建装置200可以包括创建单元210、第一关联单元220及第二关联单元230,各单元具有的功能可以如下:The virtual
创建单元210,用于通过预设开发工具及预设创建参数,创建表征虚拟PCIE设备的设备结构体,其中,所述设备结构体包括表示虚拟收包队列的第一队列结构体以及表示虚拟发包队列的第二队列结构体,所述预设创建参数包括欲创建的虚拟PCIE设备的预设数量、欲与所述虚拟PCIE设备关联的指定物理PCIE设备及预设队列映射关系;The creating
第一关联单元220,用于将所述预设数量的所述设备结构体均与所述指定物理PCIE设备关联;a
第二关联单元230,用于基于所述预设队列映射关系,将每个所述设备结构体中的所述第一队列结构体与所述指定物理PCIE设备中对应的物理收包队列关联,以及将每个所述设备结构体中的所述第二队列结构体与所述指定物理PCIE设备中对应的物理发包队列关联,得到所述预设数量的虚拟PCIE设备,其中,得到的每个所述虚拟PCIE设备用于通过所述虚拟收包队列接收数据,以及通过所述虚拟发包队列发送数据。The
可选地,第二关联单元230可以用于将每个所述设备结构体中的所述第一队列结构体与所述指定物理PCIE设备中相同的物理收包队列关联,以使每个所述设备结构体共享所述指定物理PCIE设备中相同的物理收包队列;或者,将每个所述设备结构体中的所述第一队列结构体与所述指定物理PCIE设备中的指定物理收包队列关联,其中,不同设备结构体中的所述第一队列结构体所关联的指定物理收包队列不相同。Optionally, the
可选地,第二关联单元230可以用于将每个所述设备结构体中的所述第二队列结构体与所述指定物理PCIE设备中相同的物理发包队列关联,以使每个所述设备结构体共享所述指定物理PCIE设备中相同的物理发包队列;或者,将每个所述设备结构体中的所述第二队列结构体与所述指定物理PCIE设备中的指定物理发包队列关联,其中,不同设备结构体中的所述第二队列结构体所关联的指定物理发包队列不相同。Optionally, the
可选地,虚拟设备创建装置200还可以包括添加单元。在创建单元创建表征虚拟PCIE设备的设备结构体之后,添加单元用于将创建的所述预设数量的所述设备结构体,添加于全局链表中,其中,所述全局链表中预先添加有当前网络中的所有物理PCIE设备,在所述全局链表中,每个所述设备结构体包括身份标识及表征虚拟PCIE设备的标识。Optionally, the virtual
可选地,虚拟设备创建装置200还可以包括调度单元及重定向单元。调度单元用于从所述全局链表中选择用于执行数据转发业务的当前PCIE设备;重定向单元用于当所述当前PCIE设备为虚拟PCIE设备时,将所述数据转发业务对应的待转发数据,重定向至目标物理PCIE设备中的目标物理收包队列,以接收所述待转发数据,和/或,重定向至所述目标物理PCIE设备中的目标物理发包队列,以发送所述待转发数据,其中,所述目标物理PCIE设备为与所述当前PCIE设备关联的物理PCIE设备,所述目标物理收包队列为所述目标物理PCIE设备中的与所述当前PCIE设备中的虚拟收包队列对应的物理发包队列,所述目标物理发包队列为所述目标物理PCIE设备中的与所述当前PCIE设备中的虚拟发包队列对应的物理发包队列。Optionally, the virtual
在本实施例中,处理模块11可以是一种集成电路芯片,具有信号的处理能力。上述处理模块11可以是通用处理器。例如,该处理器可以是中央处理器(Central ProcessingUnit,CPU)、数字信号处理器(Digital Signal Processing,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件,可以实现或者执行本申请实施例中的公开的各方法、步骤及逻辑框图。In this embodiment, the
存储模块12可以是,但不限于,随机存取存储器,只读存储器,可编程只读存储器,可擦除可编程只读存储器,电可擦除可编程只读存储器等。在本实施例中,存储模块12可以用于存储全局链表、预设创建参数、预设队列映射关系等。当然,存储模块12还可以用于存储程序,处理模块11在接收到执行指令后,执行该程序。The
通信模块13用于通过网络建立网络设备10与其他设备的通信连接,并通过网络收发数据。The
需要说明的是,所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的网络设备10、虚拟设备创建装置200的具体工作过程,可以参考前述方法中的各步骤对应过程,在此不再过多赘述。It should be noted that those skilled in the art can clearly understand that, for the convenience and brevity of the description, for the specific working process of the
第二实施例Second Embodiment
本申请还提供一种数据转发方法,可以应用于上述的网络设备10中。方法可以包括如下步骤:The present application also provides a data forwarding method, which can be applied to the above-mentioned
步骤S310,从全局链表中选择用于执行数据转发业务的当前PCIE设备,其中,所述全局链表中预先添加有多个PCIE设备;Step S310, selecting the current PCIE device for performing the data forwarding service from the global linked list, wherein a plurality of PCIE devices are pre-added in the global linked list;
步骤S320,当所述当前PCIE设备为虚拟PCIE设备时,将所述数据转发业务对应的待转发数据,重定向至目标物理PCIE设备中的目标物理收包队列,以接收所述待转发数据,和/或,重定向至所述目标物理PCIE设备中的目标物理发包队列,以发送所述待转发数据,其中,所述目标物理PCIE设备为与所述当前PCIE设备关联的物理PCIE设备,所述目标物理收包队列为所述目标物理PCIE设备中的与所述当前PCIE设备中的虚拟收包队列对应的物理发包队列,所述目标物理发包队列为所述目标物理PCIE设备中的与所述当前PCIE设备中的虚拟发包队列对应的物理发包队列。Step S320, when the current PCIE device is a virtual PCIE device, redirecting the data to be forwarded corresponding to the data forwarding service to the target physical packet receiving queue in the target physical PCIE device to receive the data to be forwarded, And/or, redirecting to the target physical packet sending queue in the target physical PCIE device to send the data to be forwarded, wherein the target physical PCIE device is a physical PCIE device associated with the current PCIE device, so The target physical packet receiving queue is the physical packet sending queue corresponding to the virtual packet receiving queue in the current PCIE device in the target physical PCIE device, and the target physical packet sending queue is the physical packet sending queue in the target physical PCIE device. The physical packet sending queue corresponding to the virtual packet sending queue in the current PCIE device.
可理解地,在第二实施例中,数据转发方法的实现过程可以参照第一实施例中对完成虚拟设备创建后,利用虚拟PCIE设备执行数据转发业务的流程,这里不再赘述。Understandably, in the second embodiment, for the implementation process of the data forwarding method, reference may be made to the process of using the virtual PCIE device to perform the data forwarding service after the virtual device is created in the first embodiment, which will not be repeated here.
请参照图4,本申请实施例还提供一种数据转发装置400,可以应用于上述的网络设备10中,用于执行方法中的各步骤。数据转发装置400包括至少一个可以软件或固件(Firmware)的形式存储于存储模块12中或固化在网络设备10操作系统(OperatingSystem,OS)中的软件功能模块。处理模块11用于执行存储模块12中存储的可执行模块,例如数据转发装置400所包括的软件功能模块及计算机程序等。Referring to FIG. 4 , an embodiment of the present application further provides a
数据转发装置400可以包括调度单元410及重定向单元420,各单元具有的功能可以如下:The
调度单元410,用于从全局链表中选择用于执行数据转发业务的当前PCIE设备,其中,所述全局链表中预先添加有多个PCIE设备;A
重定向单元420,用于当所述当前PCIE设备为虚拟PCIE设备时,将所述数据转发业务对应的待转发数据,重定向至目标物理PCIE设备中的目标物理收包队列,以接收所述待转发数据,和/或,重定向至所述目标物理PCIE设备中的目标物理发包队列,以发送所述待转发数据,其中,所述目标物理PCIE设备为与所述当前PCIE设备关联的物理PCIE设备,所述目标物理收包队列为所述目标物理PCIE设备中的与所述当前PCIE设备中的虚拟收包队列对应的物理发包队列,所述目标物理发包队列为所述目标物理PCIE设备中的与所述当前PCIE设备中的虚拟发包队列对应的物理发包队列。The
需要说明的是,所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的数据转发装置400的具体工作过程,可以参考前述方法中的各步骤对应过程,在此不再过多赘述。It should be noted that those skilled in the art can clearly understand that, for the convenience and brevity of the description, for the specific working process of the
本申请实施例还提供一种计算机可读存储介质。计算机可读存储介质中存储有计算机程序,当计算机程序在计算机上运行时,使得计算机执行如上述实施例中所述的虚拟设备创建方法或上述的数据转发方法。Embodiments of the present application further provide a computer-readable storage medium. A computer program is stored in the computer-readable storage medium, and when the computer program runs on the computer, the computer executes the method for creating a virtual device or the method for forwarding data as described in the foregoing embodiments.
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到本申请可以通过硬件实现,也可以借助软件加必要的通用硬件平台的方式来实现,基于这样的理解,本申请的技术方案可以以软件产品的形式体现出来,该软件产品可以存储在一个非易失性存储介质(可以是CD-ROM,U盘,移动硬盘等)中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施场景所述的方法。From the description of the above embodiments, those skilled in the art can clearly understand that the present application can be implemented by hardware or by means of software plus a necessary general hardware platform. Based on this understanding, the technical solutions of the present application It can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, U disk, mobile hard disk, etc.), and includes several instructions to make a computer device (which can be It is a personal computer, a server, or a network device, etc.) to execute the methods described in various implementation scenarios of this application.
综上所述,在本方案中,通过将预设数量的设备结构体与物理PCIE设备关联,以及将虚拟收包队列和物理收包列关联,将虚拟发包队列和物理发包队列关联,如此,一个物理PCIE设备可以创建得到多个虚拟PCIE设备,有利于物理设备的硬件资源得到充分利用,以提升处理性能,且无需依赖专门的BIOS,不需要设备支持Vd-t,提高设备虚拟化的适用范围。To sum up, in this solution, by associating a preset number of device structures with physical PCIE devices, and associating the virtual packet receiving queue with the physical packet receiving queue, the virtual packet sending queue and the physical packet sending queue are associated, so, A physical PCIE device can create multiple virtual PCIE devices, which is conducive to the full utilization of the hardware resources of the physical device to improve the processing performance, and does not need to rely on a special BIOS, does not require the device to support Vd-t, and improves the application of device virtualization. scope.
在本申请所提供的实施例中,应该理解到,所揭露的装置、系统和方法,也可以通过其它的方式实现。以上所描述的装置、系统和方法实施例仅仅是示意性的,例如,附图中的流程图和框图显示了根据本申请的多个实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段或代码的一部分,所述模块、程序段或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也要注意的是,框图和/或流程图中的每个方框、以及框图和/或流程图中的方框的组合,可以用执行规定的功能或动作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。另外,在本申请各个实施例中的各功能模块可以集成在一起形成一个独立的部分,也可以是各个模块单独存在,也可以两个或两个以上模块集成形成一个独立的部分。In the embodiments provided in this application, it should be understood that the disclosed apparatus, system and method may also be implemented in other manners. The apparatus, system and method embodiments described above are merely schematic, for example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture of possible implementations of systems, methods and computer program products according to various embodiments of the present application Architecture, functionality and operation. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code that contains one or more functions for implementing the specified logical function(s) executable instructions. It is also noted that each block of the block diagrams and/or flowchart illustrations, and combinations of blocks in the block diagrams and/or flowchart illustrations, can be implemented in dedicated hardware-based systems that perform the specified functions or actions , or can be implemented in a combination of dedicated hardware and computer instructions. In addition, each functional module in each embodiment of the present application may be integrated together to form an independent part, or each module may exist independently, or two or more modules may be integrated to form an independent part.
以上所述仅为本申请的实施例而已,并不用于限制本申请的保护范围,对于本领域的技术人员来说,本申请可以有各种更改和变化。凡在本申请的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本申请的保护范围之内。The above descriptions are merely examples of the present application, and are not intended to limit the protection scope of the present application. For those skilled in the art, the present application may have various modifications and changes. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of this application shall be included within the protection scope of this application.
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202111629680.XACN114296876A (en) | 2021-12-28 | 2021-12-28 | Virtual device creation method, data forwarding method, device and network device |
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202111629680.XACN114296876A (en) | 2021-12-28 | 2021-12-28 | Virtual device creation method, data forwarding method, device and network device |
| Publication Number | Publication Date |
|---|---|
| CN114296876Atrue CN114296876A (en) | 2022-04-08 |
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202111629680.XAPendingCN114296876A (en) | 2021-12-28 | 2021-12-28 | Virtual device creation method, data forwarding method, device and network device |
| Country | Link |
|---|---|
| CN (1) | CN114296876A (en) |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20110069710A1 (en)* | 2009-09-22 | 2011-03-24 | Virtensys Limited | Switching Method |
| US20120042034A1 (en)* | 2010-08-13 | 2012-02-16 | Vmware, Inc. | Live migration of virtual machine during direct access to storage over sr iov adapter |
| CN104428752A (en)* | 2012-06-21 | 2015-03-18 | 微软公司 | Offloading virtual machine flows to physical queues |
| CN104503838A (en)* | 2014-11-23 | 2015-04-08 | 华中科技大学 | Method for scheduling virtual CPU (Central Processing Unit) |
| CN105721566A (en)* | 2016-01-29 | 2016-06-29 | 华为技术有限公司 | Method for redirecting port, server and system |
| CN113111025A (en)* | 2021-06-10 | 2021-07-13 | 深圳市科力锐科技有限公司 | PCI equipment mapping method, device, equipment and storage medium |
| CN113312155A (en)* | 2021-07-29 | 2021-08-27 | 阿里云计算有限公司 | Virtual machine creation method, device, equipment, system and computer program product |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20110069710A1 (en)* | 2009-09-22 | 2011-03-24 | Virtensys Limited | Switching Method |
| US20120042034A1 (en)* | 2010-08-13 | 2012-02-16 | Vmware, Inc. | Live migration of virtual machine during direct access to storage over sr iov adapter |
| CN104428752A (en)* | 2012-06-21 | 2015-03-18 | 微软公司 | Offloading virtual machine flows to physical queues |
| CN104503838A (en)* | 2014-11-23 | 2015-04-08 | 华中科技大学 | Method for scheduling virtual CPU (Central Processing Unit) |
| CN105721566A (en)* | 2016-01-29 | 2016-06-29 | 华为技术有限公司 | Method for redirecting port, server and system |
| CN113111025A (en)* | 2021-06-10 | 2021-07-13 | 深圳市科力锐科技有限公司 | PCI equipment mapping method, device, equipment and storage medium |
| CN113312155A (en)* | 2021-07-29 | 2021-08-27 | 阿里云计算有限公司 | Virtual machine creation method, device, equipment, system and computer program product |
| Publication | Publication Date | Title |
|---|---|---|
| US10778521B2 (en) | Reconfiguring a server including a reconfigurable adapter device | |
| US10095645B2 (en) | Presenting multiple endpoints from an enhanced PCI express endpoint device | |
| US8830870B2 (en) | Network adapter hardware state migration discovery in a stateful environment | |
| CN110099014B (en) | Method and host for message processing in cloud computing system | |
| US9996484B1 (en) | Hardware acceleration for software emulation of PCI express compliant devices | |
| US9154451B2 (en) | Systems and methods for sharing devices in a virtualization environment | |
| US10754797B1 (en) | Consolidating write transactions for a network device | |
| CN106557444B (en) | Method and device for realizing SR-IOV network card and method and device for realizing dynamic migration | |
| US10067900B2 (en) | Virtualized I/O device sharing within a distributed processing node system | |
| WO2018133035A1 (en) | Method, network card, host device and computer system for forwarding data packages | |
| EP4004721B1 (en) | Computer device including process isolated containers with assigned virtual functions | |
| US10621124B2 (en) | Method, device and computer program product for enabling SR-IOV functions in endpoint device | |
| US11474880B2 (en) | Network state synchronization for workload migrations in edge devices | |
| WO2013049990A1 (en) | Live logical partition migration with stateful offload connections using context extraction and insertion | |
| US11343176B2 (en) | Interconnect address based QoS regulation | |
| US10911405B1 (en) | Secure environment on a server | |
| US12321301B1 (en) | Low-latency packet processing for network device | |
| US9344376B2 (en) | Quality of service in multi-tenant network | |
| US10616116B1 (en) | Network traffic load balancing using rotating hash | |
| US11899969B1 (en) | Re-order buffer for in-order execution of dependent write transactions | |
| CN116955251A (en) | Read request processing method and related device based on reorder buffer | |
| US20220147502A1 (en) | Method to perform hash table lookup for keys wider than data path size | |
| WO2018057165A1 (en) | Technologies for dynamically transitioning network traffic host buffer queues | |
| CN114697387A (en) | Data packet transmission method, device and storage medium | |
| CN114296876A (en) | Virtual device creation method, data forwarding method, device and network device |
| 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 |