CN100428171C - Communication method between data plane and control plane - Google Patents
Communication method between data plane and control plane Download PDFInfo
- Publication number
- CN100428171C CN100428171C CNB2006101619813A CN200610161981A CN100428171C CN 100428171 C CN100428171 C CN 100428171C CN B2006101619813 A CNB2006101619813 A CN B2006101619813A CN 200610161981 A CN200610161981 A CN 200610161981A CN 100428171 C CN100428171 C CN 100428171C
- Authority
- CN
- China
- Prior art keywords
- pseudo
- data
- plane
- core
- control plane
- 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.)
- Expired - Fee Related
Links
- 230000006854 communication Effects 0.000 title claims abstract description 63
- 238000004891 communication Methods 0.000 title claims abstract description 62
- 238000000034 method Methods 0.000 title claims abstract description 37
- 238000013461 design Methods 0.000 abstract description 15
- 230000002708 enhancing effect Effects 0.000 abstract description 2
- 230000005540 biological transmission Effects 0.000 description 9
- 238000007726 management method Methods 0.000 description 9
- 230000003993 interaction Effects 0.000 description 7
- 238000012545 processing Methods 0.000 description 7
- 238000010586 diagram Methods 0.000 description 6
- 238000005538 encapsulation Methods 0.000 description 4
- 230000008569 process Effects 0.000 description 4
- 230000004044 response Effects 0.000 description 4
- 230000006870 function Effects 0.000 description 3
- 230000006978 adaptation Effects 0.000 description 2
- 230000008901 benefit Effects 0.000 description 2
- 238000011022 operating instruction Methods 0.000 description 2
- 230000000052 comparative effect Effects 0.000 description 1
- 239000000284 extract Substances 0.000 description 1
- 230000002452 interceptive effect Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000003672 processing method Methods 0.000 description 1
Images
Landscapes
- Communication Control (AREA)
Abstract
本发明涉及一种数据平面与控制平面之间的通讯方法,包括以下步骤:当运行在控制平面的操作系统的用户空间应用程序向运行在控制平面的操作系统中注册的第一伪设备发送数据时,第一伪设备将数据复制到运行在控制平面的操作系统的内核空间;如果数据平面运行于多核系统,则将数据从内核空间发送到所述多核系统中注册的第二伪设备;如果数据平面运行在单核系统,则直接由第二伪设备从内核空间读取数据。在数据平面和控制平面分别注册了具有一致接口的伪设备,并将硬件环境的判断以及多核硬件时核间通信的操作封装起来,使上层业务模块的设计不需要考虑硬件环境,从而增强了上层业务模块的适应性和可扩展性。
The invention relates to a communication method between a data plane and a control plane, comprising the following steps: when a user space application program running on an operating system of the control plane sends data to a first pseudo-device registered in the operating system running on the control plane , the first pseudo-device copies the data to the kernel space of the operating system running on the control plane; if the data plane runs on a multi-core system, the data is sent from the kernel space to the second pseudo-device registered in the multi-core system; if If the data plane runs on a single-core system, the second pseudo-device directly reads data from the kernel space. Pseudo devices with consistent interfaces are registered on the data plane and control plane respectively, and the judgment of the hardware environment and the operation of multi-core hardware and inter-core communication are encapsulated, so that the design of the upper-layer business module does not need to consider the hardware environment, thereby enhancing the upper-layer Adaptability and scalability of business modules.
Description
技术领域 technical field
本发明涉及一种数通设备中数据平面与控制平面之间的通讯方法,尤其是针对多核(Multi-Core)环境下上层应用程序在执行时在数据平面与控制平面之间的进行数据通讯的方法。The invention relates to a communication method between a data plane and a control plane in a data communication device, especially for performing data communication between the data plane and the control plane when an upper-layer application program is executed in a multi-core (Multi-Core) environment method.
背景技术 Background technique
数通设备(用于数据通讯的设备,例如路由器等)按照工作职能的不同一般可以在逻辑上分为数据平面(DATA PLANE)和控制平面(CONTROL PLANE)两部分,其中数据平面主要负责对网络报文的高速处理,而控制平面主要运行管理软件负责对整个系统的配置以及运行一些控制层的协议。Data communication equipment (equipment used for data communication, such as routers, etc.) can generally be logically divided into two parts: data plane (DATA PLANE) and control plane (CONTROL PLANE) according to different job functions. High-speed processing of messages, while the control plane mainly runs management software, which is responsible for configuring the entire system and running some control layer protocols.
在一般的单核(Single-Core)系统中,数据平面和控制平面在物理上不是相分离的结构,它们共享一个CPU,并交替获得CPU时间以运行在它们的程序。以采用Linux作为操作系统的数通设备为例,假设控制平面运行于Linux的用户空间,而数据平面运行在Linux的内核空间。由于Linux的用户空间和内核空间的内存是相互隔离的,因此运行在Linux控制平面的管理程序在与数据平面的程序交互时,就必须通过用户空间与内核空间的通讯实现。实际上,用户空间和内核空间在操作系统中只是被逻辑上隔离,它们可以共享一个内存空间,因此数据平面和控制平面一般采用共享内存的方式进行通讯。In a general single-core (Single-Core) system, the data plane and the control plane are not physically separated structures. They share a CPU and alternately obtain CPU time to run their programs. Taking a datacom device using Linux as an operating system as an example, it is assumed that the control plane runs in the user space of Linux, and the data plane runs in the kernel space of Linux. Since the memory of Linux user space and kernel space are isolated from each other, when the hypervisor running on the Linux control plane interacts with the program of the data plane, it must be realized through the communication between the user space and the kernel space. In fact, user space and kernel space are only logically isolated in the operating system, and they can share a memory space. Therefore, the data plane and the control plane generally use shared memory to communicate.
多核CPU的出现为数据平面和控制平面的以更高的效率运行提供了很好的条件。在多核系统设计中,可以根据多核CPU中的每个核(Core)处理功能的不同分成两类,其中一类运行数据平面的操作系统和应用程序,另一类运行控制平面的操作系统和应用程序。The emergence of multi-core CPU provides good conditions for the data plane and control plane to run with higher efficiency. In the multi-core system design, it can be divided into two categories according to the different processing functions of each core (Core) in the multi-core CPU, one of which runs the operating system and applications on the data plane, and the other runs the operating system and applications on the control plane. program.
按照这种分类方法,可以选择在多核CPU中的一个核上运行控制平面系统和程序,控制平面使用Linux操作系统,用于提供通用开放的管理配置平台;其他的核上运行数据平面系统和程序,数据平面上运行与应用相关的专用的系统和专用程序。数据平面系统和控制平面系统具有共用的物理内存。According to this classification method, you can choose to run the control plane system and program on one core of the multi-core CPU. The control plane uses the Linux operating system to provide a general and open management configuration platform; the data plane system and program run on other cores. , running dedicated systems and programs related to applications on the data plane. The data plane system and the control plane system have a shared physical memory.
这种分工明显可以带来数据处理效率的提高,但由于两个平面运行在不同的核上,逻辑上使用不同的内存空间,因此可以被看作是两台设备。这样的系统设计方法必然要考虑基于多核CPU的数据平面和控制平面的通讯方式。This division of labor can obviously improve data processing efficiency, but since the two planes run on different cores and logically use different memory spaces, they can be regarded as two devices. Such a system design method must consider the communication mode of the data plane and the control plane based on the multi-core CPU.
现有的多核CPU提供了核间高速通讯通路API(即由多核CPU硬件实现的核间高速通信通路),这种核间高速通讯通路的方式适合在核间进行少量数据的高速发送,是解决运行数据平面的核与运行控制平面的核之间的通讯的基础。但是对于核间大量数据的发送,则需要核间高速通讯通路结合共享内存的方式实现。The existing multi-core CPU provides an inter-core high-speed communication path API (i.e., an inter-core high-speed communication path realized by the multi-core CPU hardware). The basis for communication between cores running the data plane and cores running the control plane. However, for the transmission of a large amount of data between cores, a high-speed communication path between cores combined with shared memory is required.
上述的技术方案虽然解决了多核CPU的环境下数据平面和控制平面间的通信问题,但底层的应用程序接口缺少封装,运行在数据平面或控制平面中的上层应用程序在通讯时需要直接对底层的API进行控制,在程序设计上就须考虑底层硬件的情况而设计相应的处理方式,难以实现硬件无关性,设计难度较大,不易移植。Although the above-mentioned technical solution solves the communication problem between the data plane and the control plane in the multi-core CPU environment, the application program interface of the bottom layer lacks encapsulation. API to control, in the program design must consider the situation of the underlying hardware and design the corresponding processing method, it is difficult to achieve hardware independence, the design is difficult, and it is not easy to transplant.
发明内容 Contents of the invention
本发明的目的是提出一种数据平面与控制平面之间的通讯方法,能够使数据平面或控制平面的上层业务模块在设计时不必考虑底层的硬件差异,既适用于多核环境,也可以应用于单核环境。The purpose of the present invention is to propose a communication method between the data plane and the control plane, so that the upper layer business modules of the data plane or the control plane do not need to consider the underlying hardware differences when designing, and are applicable to both multi-core environments and single-core environment.
为实现上述目的,本发明提供了一种数据平面与控制平面之间的通讯方法,包括以下步骤:In order to achieve the above object, the present invention provides a communication method between a data plane and a control plane, comprising the following steps:
当运行在控制平面的操作系统的用户空间应用程序向运行在控制平面的操作系统中注册的第一伪设备发送数据时,所述第一伪设备将数据复制到所述运行在控制平面的操作系统的内核空间;When a user space application running on the operating system on the control plane sends data to a first pseudo-device registered in the operating system running on the control plane, the first pseudo-device copies the data to the operating system running on the control plane The kernel space of the system;
第一伪设备判断如果所述数据平面是否运行于多核系统硬件,是则将数据从所述内核空间发送到运行在数据平面的操作所述多核系统数据平面中注册的第二伪设备。If the first pseudo-device judges whether the data plane runs on multi-core system hardware, if yes, it sends data from the kernel space to the second pseudo-device registered in the multi-core system data plane running on the data plane.
在上述技术方案中,如果所述数据平面运行于单核系统,否则直接由所述第二伪设备从所述内核空间读取数据。In the above technical solution, if the data plane runs on a single-core system, otherwise, the second dummy device directly reads data from the kernel space.
伪设备将硬件底层的操作封装起来,能够根据单核硬件和多核硬件的硬件环境进行数据传送,上层应用程序调用伪设备在数据平面和控制平面之间进行通讯时,不需考虑底层的通讯实现方式,降低了应用程序设计上的难度,也实现了在单核硬件和多核硬件上的可移植性。The pseudo-device encapsulates the underlying operations of the hardware, and can transmit data according to the hardware environment of single-core hardware and multi-core hardware. When the upper-layer application calls the pseudo-device to communicate between the data plane and the control plane, it does not need to consider the underlying communication implementation. The method reduces the difficulty of application program design and realizes portability on single-core hardware and multi-core hardware.
当所述用户空间应用程序向第一伪设备发送的数据为操作指令时,所述将数据从所述内核空间发送到运行在数据平面的操作系统中注册的第二伪设备的操作具体为:When the data sent by the user space application to the first pseudo-device is an operation instruction, the operation of sending the data from the kernel space to the second pseudo-device registered in the operating system running on the data plane is specifically:
将所述第一伪设备的设备信息和该操作指令封装为消息,并通过核间高速通讯通道将所述消息从所述内核空间发送到运行在数据平面的操作系统;Encapsulating the device information of the first pseudo-device and the operation instruction into a message, and sending the message from the kernel space to an operating system running on a data plane through an inter-core high-speed communication channel;
所述运行在数据平面的操作系统解析出该消息中的第一伪设备的设备信息和操作指令,并根据该设备信息查找对应的第二伪设备,然后提供给该第二伪设备该操作指令以使该第二伪设备执行相应操作。The operating system running on the data plane parses out the device information and operation instructions of the first pseudo-device in the message, searches for the corresponding second pseudo-device according to the device information, and then provides the operation instruction to the second pseudo-device so that the second pseudo-device performs a corresponding operation.
如果控制平面与数据平面交互的数据为用于配置数据平面的配置信息,所述将数据从所述内核空间发送到所述多核系统数据平面中注册的第二伪设备的操作具体为:If the data interacted between the control plane and the data plane is configuration information for configuring the data plane, the operation of sending the data from the kernel space to the second pseudo-device registered in the data plane of the multi-core system is specifically:
调用核间高速通讯通道将该配置信息从所述内核空间发送到所述多核系统,所述多核系统根据该配置信息对第二伪设备进行配置操作。The inter-core high-speed communication channel is called to send the configuration information from the kernel space to the multi-core system, and the multi-core system configures the second pseudo-device according to the configuration information.
除了对多核硬件和单核硬件的封装外,还可以在控制平面和数据平面之间数据的传输方式上进行封装,所述将数据从所述内核空间发送到所述多核系统数据平面中注册的第二伪设备的操作具体为:第一伪设备判断所述数据是否低于预设的容量阈值,是则将数据封装为消息,并通过内核空间所在的CPU核经由核间高速通讯通路,发送到所述多核系统数据平面所在的CPU核;否则将所述内核空间所在的CPU核将数据写入共享内存,并将数据的内存地址封装成消息,通过核间高速通讯通路发送到所述多核系统数据平面所在的CPU核,再由所述多核系统所在的CPU核根据所述消息中的内存地址将数据从共享内存中取出。In addition to the encapsulation of multi-core hardware and single-core hardware, encapsulation can also be performed on the data transmission mode between the control plane and the data plane, and the data is sent from the kernel space to the multi-core system registered in the data plane. The operation of the second pseudo-device is specifically: the first pseudo-device judges whether the data is lower than the preset capacity threshold, and if so, encapsulates the data into a message, and sends the to the CPU core where the data plane of the multi-core system is located; otherwise, the CPU core where the kernel space is located writes the data into the shared memory, and encapsulates the memory address of the data into a message, and sends it to the multi-core through the inter-core high-speed communication channel The CPU core where the system data plane is located, and then the CPU core where the multi-core system is located fetches data from the shared memory according to the memory address in the message.
核间高速通讯通路适合于核间的少量数据的高速传输,当核间需要传输的数据量较大时,则需要结合核间高速通讯通路和共享内存来实现核间的数据传输。在数据平面和控制平面各自的操作系统初始化时,可将共享内存区映射到同一个物理地址的内存块上,这个内存块相对于各自的操作系统是独立的,这时两个平面的系统都可以对共享内存进行访问。在通讯时,作为发送方的CPU核将需要交互的数据写入共享内存中,并将内存地址封装在核间高速通讯通道的消息中,并将该消息发到作为目的方的CPU核上,作为目的方的CPU核对接收到的消息进行解析后,按照消息中的物理地址从共享内存中将数据取出。The inter-core high-speed communication path is suitable for the high-speed transmission of a small amount of data between the cores. When the amount of data to be transmitted between the cores is large, it is necessary to combine the inter-core high-speed communication path and shared memory to realize the inter-core data transmission. When the respective operating systems of the data plane and the control plane are initialized, the shared memory area can be mapped to a memory block at the same physical address. This memory block is independent from the respective operating systems. At this time, the two plane systems are Access to shared memory is possible. During communication, the CPU core as the sender writes the data that needs to be interacted into the shared memory, encapsulates the memory address in the message of the inter-core high-speed communication channel, and sends the message to the CPU core as the destination. After parsing the received message, the CPU as the destination takes out the data from the shared memory according to the physical address in the message.
进一步地,当数据平面运行在单核环境时,用户空间和内核空间都处于同一个CPU核,因此第二伪设备可以直接访问所述运行在控制平面的操作系统的内核空间的共享内存,并读取数据。Further, when the data plane runs in a single-core environment, the user space and the kernel space are in the same CPU core, so the second pseudo-device can directly access the shared memory of the kernel space of the operating system running on the control plane, and read data.
在注册第一伪设备和第二伪设备时,为所述第一伪设备和第二伪设备设置一致的操作接口,能够极大的简化上层程序的设计难度。When registering the first pseudo-device and the second pseudo-device, setting a consistent operation interface for the first pseudo-device and the second pseudo-device can greatly simplify the design difficulty of the upper layer program.
为第一伪设备和第二伪设备设置操作接口时,可以设置一致的字符型设备操作接口,所述字符型设备操作包括打开伪设备、关闭伪设备、从伪设备中读取数据、向伪设备写入数据、向伪设备发送操作指令和从伪设备读取状态信息中的一种或多种操作。When setting the operation interface for the first pseudo-device and the second pseudo-device, a consistent character-type device operation interface can be set, and the operation of the character-type device includes opening the pseudo-device, closing the pseudo-device, reading data from the pseudo-device, One or more operations in which the device writes data, sends operation instructions to the pseudo-device, and reads status information from the pseudo-device.
也可以设置一致的网络操作接口,在运行在数据平面的操作系统中注册第二伪设备时,为所述数据平面分配IP地址,并在所述运行在控制平面的操作系统中增加到数据平面的通讯路由表。采用的这种网络设备方式,可以使第二伪设备以及在第二伪设备通信时采用的共享内存和核间高速通讯通道封装成一个网络设备,从而使控制平面和数据平面的交互视为两台网络设备之间的交互,这种交互利用TCP/IP协议,并通过Socket(套接字)的方式来实现通讯。由于TCP/IP协议的普及性,因此采用这种方式的可扩展性和适应性都较强。It is also possible to set a consistent network operation interface, when registering the second pseudo-device in the operating system running on the data plane, assign an IP address to the data plane, and add it to the data plane in the operating system running on the control plane communication routing table. The network device method adopted can encapsulate the second pseudo-device and the shared memory and inter-core high-speed communication channel used in the communication of the second pseudo-device into one network device, so that the interaction between the control plane and the data plane can be regarded as two Interaction between network devices, this interaction uses TCP/IP protocol, and realizes communication through Socket (socket). Due to the popularity of the TCP/IP protocol, this method has strong scalability and adaptability.
基于上述技术方案,本发明具有以下优点:Based on the above technical scheme, the present invention has the following advantages:
1、本发明在数据平面和控制平面采用伪设备进行数据传输,由伪设备将硬件环境的判断以及具体到多核硬件的核间通信的操作封装起来,使上层业务模块的设计不需要考虑硬件环境,从而增强了上层业务模块的适应性和可扩展性。1. The present invention uses pseudo-device for data transmission on the data plane and control plane. The pseudo-device encapsulates the judgment of the hardware environment and the operation of inter-core communication specific to multi-core hardware, so that the design of the upper-layer business module does not need to consider the hardware environment. , thus enhancing the adaptability and scalability of the upper layer business modules.
2、本发明针对操作系统中适用的设备管理方式来设计伪设备的管理方式,使其易于兼容,在设计时可以采用字符设备或块设备管理方式,也可以采用网络管理方式,因此也具有较大的灵活性。2. The present invention designs the pseudo-device management method for the applicable device management method in the operating system to make it easy to be compatible. The character device or block device management method can be used in the design, and the network management method can also be used, so it also has a comparative advantage. Great flexibility.
3、本发明在不同硬件环境下都为上层应用程序提供了统一的操作接口,极大的简化了上层应用程序的设计。3. The present invention provides a unified operation interface for upper-layer application programs under different hardware environments, which greatly simplifies the design of upper-layer application programs.
下面通过附图和实施例,对本发明的技术方案做进一步的详细描述。The technical solutions of the present invention will be described in further detail below with reference to the accompanying drawings and embodiments.
附图说明 Description of drawings
图1为本发明应用于单核环境下的结构示意图。FIG. 1 is a schematic diagram of the structure of the present invention applied in a single-core environment.
图2为本发明应用于多核环境下的结构示意图。FIG. 2 is a schematic diagram of the structure of the present invention applied in a multi-core environment.
图3为本发明数据平面与控制平面的通讯方法的一实施例的流程示意图。FIG. 3 is a schematic flowchart of an embodiment of a communication method between a data plane and a control plane according to the present invention.
图4为本发明数据平面与控制平面的通讯方法的另一实施例的流程示意图。FIG. 4 is a schematic flowchart of another embodiment of the communication method between the data plane and the control plane of the present invention.
图5为本发明数据平面与控制平面的通讯方法的又一实施例的流程示意图。FIG. 5 is a schematic flowchart of another embodiment of the communication method between the data plane and the control plane of the present invention.
具体实施方式 Detailed ways
本发明的原理是利用在操作系统中注册的伪设备(pseudo-device)来完成数据平面和控制平面的数据通讯,并由伪设备封装对硬件环境和/或数据传输方式的适配过程,伪设备的接口采用统一的接口,使上层应用程序在设计时得到极大的简化,且不必考虑其硬件环境所造成的影响。The principle of the present invention is to use the pseudo-device registered in the operating system to complete the data communication between the data plane and the control plane, and the pseudo-device encapsulates the adaptation process to the hardware environment and/or data transmission mode. The interface of the device adopts a unified interface, which greatly simplifies the design of the upper layer application program, and does not have to consider the impact caused by its hardware environment.
如图1所示,为本发明应用于单核环境下的结构示意图。在单核CPU中运行操作系统,该操作系统包括用户空间和内核空间,用户空间和内核空间即表示操作系统的不同运行态,其中数据平面运行于内核空间,控制平面运行于用户空间。在用户空间中运行有控制平面应用程序1,可以对数据平面中的数据平面应用程序2进行操作,数据平面应用程序2与控制平面应用程序1进行数据交互,在系统启动时,会在用户空间和内核空间分别注册伪设备3和伪设备4,伪设备3和伪设备4的接口定义需设置一致,伪设备3和伪设备4之间的数据交互通过共享内存的方式来实现。As shown in FIG. 1 , it is a schematic diagram of the structure of the present invention applied in a single-core environment. An operating system is run in a single-core CPU, and the operating system includes user space and kernel space. The user space and kernel space represent different operating states of the operating system. The data plane runs in the kernel space, and the control plane runs in the user space. There is a
对于多核环境,如图2所示,本发明应用于多核环境下的结构示意图。控制平面运行在控制平面CPU上,在控制平面上运行着操作系统,数据平面运行于数据平面CPU上,该数据平面CPU是区别于控制平面CPU的其它核,在数据平面中运行着专用的操作系统及程序,例如一些专用嵌入式系统。在控制平面中运行有控制平面应用程序1,能够对数据平面上的数据平面应用程序2进行操作,数据平面应用程序2与控制平面应用程序1进行数据交互。在系统启动时,在控制平面中注册伪设备3’,在数据平面中注册伪设备4’,与单核环境一样,其接口定义可以与伪设备3’相一致。For a multi-core environment, as shown in FIG. 2 , a schematic structural diagram of the present invention applied in a multi-core environment. The control plane runs on the control plane CPU, the operating system runs on the control plane, and the data plane runs on the data plane CPU. The data plane CPU is a core different from the control plane CPU, and runs dedicated operations in the data plane. Systems and programs, such as some dedicated embedded systems. The
本发明的基本过程如图3所示,为本发明数据平面与控制平面的通讯方法的一实施例的流程示意图,包括以下步骤:The basic process of the present invention is shown in Figure 3, which is a schematic flow diagram of an embodiment of the communication method between the data plane and the control plane of the present invention, including the following steps:
步骤101,当运行在控制平面的操作系统的用户空间应用程序向运行在控制平面的操作系统中注册的第一伪设备发送数据时,所述第一伪设备将数据复制到所述运行在控制平面的操作系统的内核空间;
步骤102,如果数据平面运行于多核系统,则执行步骤103;如果运行于单核系统,则执行步骤104;
步骤103,将数据从内核空间发送到所述多核系统中注册的第二伪设备,并结束操作;
步骤104,直接由所述第二伪设备从所述内核空间读取数据。In
伪设备在设计时可针对于多核系统或单核系统通过宏来实现不同的程序构架,当对于多核系统或单核系统对伪设备程序进行编译时,选择多核系统或单核系统相对应的宏执行编译操作。编译后的伪设备程序能够为多核系统或单核系统提供上层应用的接口,使上层的应用程序能够不必针对多核系统或单核系统实现对应的程序框架,从而简化了程序设计。When designing pseudo-device, different program structures can be realized through macros for multi-core systems or single-core systems. When compiling pseudo-device programs for multi-core systems or single-core systems, select the corresponding macros for multi-core systems or single-core systems. Perform a compile operation. The compiled pseudo-device program can provide an upper-layer application interface for the multi-core system or single-core system, so that the upper-layer application program does not need to implement a corresponding program framework for the multi-core system or single-core system, thereby simplifying the program design.
在数通设备启动时,会进行注册伪设备的操作,在注册过程中可为第二伪设备设置与第一伪设备一致的操作接口。这样可以降低上层应用程序的设计难度,使上层应用程序具有良好的可移植性。在内核空间与数据平面进行数据交互时,还需要对硬件环境进行判断以选择不同的处理过程。When the datacom device is started, the operation of registering the pseudo-device will be performed, and the operation interface consistent with that of the first pseudo-device can be set for the second pseudo-device during the registration process. In this way, the design difficulty of the upper-layer application program can be reduced, and the upper-layer application program has good portability. When performing data interaction between the kernel space and the data plane, it is also necessary to judge the hardware environment to select different processing procedures.
当数通设备为多核硬件环境时,伪设备在传输数据时可以利用核间高速通讯通路进行传输,请参看图4,为本发明数据平面与控制平面的通讯方法的另一实施例的流程示意图,包括以下步骤:When the data communication device is a multi-core hardware environment, the pseudo-device can use the inter-core high-speed communication path to transmit data. Please refer to FIG. 4, which is a schematic flow diagram of another embodiment of the communication method between the data plane and the control plane of the present invention , including the following steps:
步骤101,当运行在控制平面的操作系统的用户空间应用程序向运行在控制平面的操作系统中注册的第一伪设备发送数据时,所述第一伪设备将数据复制到所述运行在控制平面的操作系统的内核空间;
步骤102,如果所述数据平面运行于多核系统,则执行步骤103a;如果数据平面运行于单核系统,则执行步骤104’;
步骤103a,将第一伪设备的设备信息和操作指令封装为消息,并将所述消息从所述内核空间发送到运行在数据平面的操作系统;
步骤103b,解析出该消息中的第一伪设备的设备信息和操作指令,查找对应于该设备信息的第二伪设备,并根据该操作指令进行操作,然后结束操作;
步骤104’,第二伪设备直接访问所述运行在控制平面的操作系统的内核空间的共享内存,并读取数据。Step 104', the second pseudo-device directly accesses the shared memory in the kernel space of the operating system running on the control plane, and reads data.
由于数据平面中已经注册了第二伪设备的设备信息,在接收到消息后,根据解析出的第一伪设备的设备信息(可以为伪设备名、设备参数等)可以相应的查找出第二伪设备,并由第二伪设备根据操作指令执行相应的操作。在单核环境下,由于控制平面和数据平面实际处于同一种操作系统的不同运行态,因此第二伪设备可以直接读取数据,如果数据为某种操作指令,则执行相应的操作。Since the device information of the second pseudo-device has been registered in the data plane, after receiving the message, the device information of the first pseudo-device (which can be pseudo-device name, device parameters, etc.) can be found out correspondingly. pseudo-device, and the second pseudo-device performs corresponding operations according to the operation instructions. In a single-core environment, since the control plane and the data plane are actually in different operating states of the same operating system, the second pseudo-device can directly read data, and execute corresponding operations if the data is a certain operation instruction.
运行在控制平面的多种操作系统下都可以使用伪设备,如FreeBSD、Solaris和Linux等,下面以Linux为例,提供伪设备的接口定义的一个实例,这里以C语言作实例说明。Pseudo-devices can be used under various operating systems running on the control plane, such as FreeBSD, Solaris, and Linux. The following takes Linux as an example to provide an example of the interface definition of a pseudo-device. Here, the C language is used as an example.
Linux中通过register_chrdev(unsigned int major,const char*name,struct file_operations*fops)和unregister_chrdev(unsignedint major,const char*name)定义伪设备的注册和卸载接口,其中constchar*name为伪设备的注册名,是Linux用户态程序访问该设备时需要指定的名称,然后可以根据需要选择操作接口,例如选择字符型设备操作接口和网络操作接口。In Linux, register_chrdev(unsigned int major, const char*name, struct file_operations*fops) and unregister_chrdev(unsignedint major, const char*name) define the registration and unloading interface of the pseudo-device, where constchar*name is the registration name of the pseudo-device, It is the name that needs to be specified when the Linux user mode program accesses the device, and then the operation interface can be selected as required, such as selecting the character device operation interface and the network operation interface.
先以字符型设备操作接口为例,字符型设备操作可以包括:打开伪设备(open)、关闭伪设备(close)、从伪设备中读取数据(read)、向伪设备写入数据(write)、向伪设备发送操作指令和从伪设备读取状态信息(ioctl)中的一种或多种操作。其中在对伪设备进行操作前,需要先执行打开伪设备的操作。First take the character device operation interface as an example, the character device operations can include: open the pseudo device (open), close the pseudo device (close), read data from the pseudo device (read), write data to the pseudo device (write ), sending operation instructions to the pseudo-device and reading status information (ioctl) from the pseudo-device. Before performing operations on the pseudo-device, the operation of opening the pseudo-device needs to be performed first.
这种字符型设备操作接口在伪设备采用字符设备方式或块设备方式时使用,而这两种设备管理方式都与Linux中的设备管理方式是一致的。This character-type device operation interface is used when the pseudo-device adopts the character device mode or the block device mode, and these two device management modes are consistent with the device management mode in Linux.
本发明还提供了伪设备的另一种设备管理方式:网络设备方式。其采用的操作接口为网络操作接口,与字符型设备操作接口相比,除了打开、关闭等操作外,需要通过套接字进行数据的交互传输。在运行在数据平面的操作系统中注册第二伪设备时,需要为数据平面分配IP地址,并在运行在控制平面的操作系统中增加到数据平面的通讯路由表。The present invention also provides another device management mode of pseudo-device: network device mode. The operation interface it adopts is a network operation interface. Compared with the character-type device operation interface, in addition to operations such as opening and closing, it needs to perform data interactive transmission through sockets. When registering the second pseudo-device in the operating system running on the data plane, it is necessary to allocate an IP address for the data plane, and add to the communication routing table of the data plane in the operating system running on the control plane.
下面再具体说明字符型设备操作接口中向伪设备发送操作指令和从伪设备读取状态信息(Ioctl)的接口,这个接口可以对设备进行配置,完成控制平面和数据平面的指令和数据交互。The following describes in detail the interface for sending operation instructions to the pseudo-device and reading status information (Ioctl) from the pseudo-device in the character-type device operation interface. This interface can configure the device and complete the command and data interaction between the control plane and the data plane.
当用户空间的应用程序向第一伪设备发送的数据为用于配置数据平面的配置信息时,可以利用Ioctl接口进行操作,首先第一伪设备将该配置信息复制到运行在控制平面的操作系统的内核空间;如果数据平面运行于多核系统,则调用核间高速通讯通道将该配置信息进行封装后,从内核空间发送到多核系统,多核系统根据该配置信息对第二伪设备进行配置操作;如果数据平面运行在单核系统,则第二伪设备直接从所述内核空间读取该配置信息,并进行配置操作。在配置后可以根据需要选择是否向用户空间返回信息。When the data sent by the application program in the user space to the first pseudo-device is the configuration information used to configure the data plane, the Ioctl interface can be used to operate. First, the first pseudo-device copies the configuration information to the operating system running on the control plane. kernel space; if the data plane runs in a multi-core system, call the inter-core high-speed communication channel to encapsulate the configuration information, and send it from the kernel space to the multi-core system, and the multi-core system configures the second pseudo-device according to the configuration information; If the data plane runs on a single-core system, the second pseudo-device directly reads the configuration information from the kernel space and performs a configuration operation. After configuration, you can choose whether to return information to user space according to your needs.
对于多核系统来说,运行在控制平面的操作系统将Ioctl操作指令封装到指定的消息格式中,然后调用多核的核间高速通道发送到数据平面所在核进行处理。处理完成后,数据平面所在核将返回值封装在消息中,发回控制平面所在核,然后按照回应消息的内容将结果返回用户空间应用程序。For a multi-core system, the operating system running on the control plane encapsulates the Ioctl operation instruction into a specified message format, and then calls the multi-core inter-core high-speed channel to send it to the core where the data plane is located for processing. After the processing is completed, the core where the data plane is located encapsulates the return value in a message, sends it back to the core where the control plane is located, and then returns the result to the user space application according to the content of the response message.
以下用C语言给出消息的格式,本发明提供的消息格式只为示例,并不作为对消息格式的限定。The format of the message is given below in C language, and the format of the message provided by the present invention is only an example, and is not intended as a limitation on the format of the message.
struct ioctl_msgstruct ioctl_msg
{{
unsigned short tunnel_id;/*接收应答的消息队列ID*/ unsigned short tunnel_id; /*Receive message queue ID*/
unsigned long addr; /*ioctl命令内容地址指针*/unsigned long addr; /*ioctl command content address pointer*/
chardev_name[DEV_NAME_LEN_MAX]; /*伪设备名*/ chardev_name[DEV_NAME_LEN_MAX]; /*pseudo-device name*/
unsigned int ioctl_cmd; /*ioctl命令号*/unsigned int ioctl_cmd; /*ioctl command number*/
int ret; /*ioctl执行结果返回值*/ int ret; /*ioctl execution result return value*/
};};
以上实例都是以C语言实现的,但这并不限制本发明的实现语言为C语言,其他能够实现伪设备的高级语言或者汇编语言都应在本发明的覆盖之内。The above examples are all implemented in C language, but this does not limit the implementation language of the present invention to C language, and other high-level languages or assembly languages that can realize pseudo-device should be covered by the present invention.
下面给出基于上述消息格式的通讯过程,第一伪设备先从命令号中取出Ioctl下发的缓冲区的长度,并申请一块共享内存,当配置下发命令时,从用户空间将ioctl下发的缓冲区内容复制到共享内存中;然后将ioctl命令号、伪设备名和共享内存的物理地址封装到消息格式中,并发送消息;在运行在数据平面的操作系统查找到第二伪设备后,由第二伪设备将应答消息接收队列封装到消息格式中,并从应答接收队列接收应答消息,然后从消息中取出ioctl返回码。当ioctl命令为读取配置,则从消息中取出Ioctl输出缓冲区的地址并将共享内存中的内容写回用户空间,然后释放共享内存,并将返回码返回。The communication process based on the above message format is given below. The first pseudo-device first takes out the length of the buffer area issued by Ioctl from the command number, and applies for a piece of shared memory. When the configuration is issued, the ioctl is issued from the user space. Copy the contents of the buffer to the shared memory; then encapsulate the ioctl command number, the pseudo-device name and the physical address of the shared memory into the message format, and send the message; after the operating system running on the data plane finds the second pseudo-device, The second pseudo-device encapsulates the response message receiving queue into a message format, receives the response message from the response receiving queue, and then extracts the ioctl return code from the message. When the ioctl command reads the configuration, the address of the Ioctl output buffer is taken out from the message and the content in the shared memory is written back to the user space, then the shared memory is released, and the return code is returned.
如果使运行在数据平面的上层业务模块在与控制平面内的控制平面应用程序在数据交互时不需考虑硬件的影响,则这种上层业务模块就可以运行在专用的嵌入式系统中,以嵌入式系统为例,在系统启动时需要注册一个与运行在控制平面的操作系统中伪设备接口一致的伪设备,依旧以C的实现方式举例,如下:If the upper-layer business modules running on the data plane do not need to consider the influence of the hardware when interacting with the control plane applications in the control plane, this upper-layer business module can run in a dedicated embedded system to embed For example, when the system is started, it is necessary to register a pseudo-device that is consistent with the interface of the pseudo-device in the operating system running on the control plane. The implementation method of C is still used as an example, as follows:
除了注册、卸载接口的定义外,还需要实现对多核系统的嵌入式系统中伪设备的管理,保存伪设备注册信息。在嵌入式系统接收到消息后进行解析,根据解析后消息中的伪设备的设备名查找注册过的伪设备,并执行该伪设备注册过的操作。在嵌入式系统处理完成rpc_ioctl命令后,需要将返回值和输出的缓冲区的地址封装到上述消息格式中,通过消息环将消息发送回多核系统控制平面所在核。以上描述了伪设备封装了多核环境和单核环境的硬件影响,对于多核环境下消息传递的方式还可以进一步的封装,如图5所示,为本发明数据平面与控制平面的通讯方法的另一实施例的流程示意图,包括以下步骤:In addition to the definition of registration and uninstallation interfaces, it is also necessary to realize the management of pseudo-device in the embedded system of multi-core system and save the registration information of pseudo-device. After the embedded system receives the message, it parses, searches for the registered pseudo-device according to the device name of the pseudo-device in the parsed message, and executes the registered operation of the pseudo-device. After the embedded system finishes processing the rpc_ioctl command, it needs to encapsulate the return value and the address of the output buffer into the above message format, and send the message back to the core where the control plane of the multi-core system is located through the message ring. It has been described above that the pseudo-device encapsulates the hardware impact of the multi-core environment and the single-core environment. The method of message transmission in the multi-core environment can be further encapsulated, as shown in FIG. 5, which is another communication method between the data plane and the control plane of the present invention. A schematic flow chart of an embodiment includes the following steps:
步骤101,当运行在控制平面的操作系统的用户空间应用程序向运行在控制平面的操作系统中注册的第一伪设备发送数据时,所述第一伪设备将数据复制到所述运行在控制平面的操作系统的内核空间;
步骤102,第一伪设备判断所述数据平面是否运行于多核硬件,如果运行于多核硬件,则执行步骤1031,如果运行单核硬件,则执行步骤104’;
步骤1031,第一伪设备判断被传输的数据是否低于预设的容量阈值,是则执行步骤1035,否则执行步骤1032;Step 1031, the first dummy device judges whether the transmitted data is lower than the preset capacity threshold, if yes, execute step 1035, otherwise execute step 1032;
步骤1032,内核空间所在的CPU核将数据写入共享内存;Step 1032, the CPU core where the kernel space is located writes data into the shared memory;
步骤1033,将数据的内存地址封装成消息,通过核间高速通讯通路发送到运行在数据平面的操作系统所在的CPU核;Step 1033, encapsulate the memory address of the data into a message, and send it to the CPU core where the operating system running on the data plane is located through the inter-core high-speed communication channel;
步骤1034,由运行在数据平面的操作系统所在的CPU核根据所述消息中的内存地址将数据从共享内存中取出,并结束操作;Step 1034, the CPU core where the operating system running on the data plane is located takes the data out of the shared memory according to the memory address in the message, and ends the operation;
步骤1035,将数据封装为消息,并通过内核空间所在的CPU核经由核间高速通讯通路,发送到运行在数据平面的操作系统所在的CPU核,并结束操作;In step 1035, the data is encapsulated into a message, and the CPU core where the kernel space is located is sent to the CPU core where the operating system running on the data plane is located via the inter-core high-speed communication channel, and the operation is terminated;
步骤104’,第二伪设备直接访问所述运行在控制平面的操作系统的内核空间的共享内存,并读取数据。Step 104', the second pseudo-device directly accesses the shared memory in the kernel space of the operating system running on the control plane, and reads data.
本实施例提供了控制平面与数据平面之间数据传输的进一步封装,即采用核间高速通讯通道和共享内存的结合方式,其中核间高速通讯通道中利用消息来传输数据,在消息中通常需要封装伪设备的识别标志。如本实施例所述,在核间高速通讯通道传输的消息只能够运送较少容量的数据,如果需要传输较大量的数据,就需要借助于共享内存的方式,这时消息的作用便是传送数据所在的物理地址。This embodiment provides further encapsulation of data transmission between the control plane and the data plane, that is, a combination of inter-core high-speed communication channel and shared memory is adopted, wherein the inter-core high-speed communication channel uses messages to transmit data, and messages usually require Encapsulates the identifying flag of the pseudo-device. As described in this embodiment, the messages transmitted on the inter-core high-speed communication channel can only transport a small amount of data. If a large amount of data needs to be transmitted, it is necessary to use the shared memory method. At this time, the function of the message is to transmit The physical address where the data resides.
从上述具体流程可以看出,上层业务模块和应用程序在设计时只需利用统一的程序接口进行设计即可,不需要考虑复杂的硬件环境,对硬件环境和通讯方式的适配都由伪设备来完成,从用户设计和使用的角度都屏蔽了硬件的影响,因此降低了设计难度。由于各种伪设备都可采用统一的接口,上层业务模块也因此具备了良好的可扩展性和可移植性。It can be seen from the above specific process that the upper-layer business modules and application programs only need to use a unified program interface for design, and do not need to consider the complex hardware environment. The adaptation of the hardware environment and communication methods is done by the pseudo-device From the perspective of user design and use, the influence of hardware is shielded, thus reducing the difficulty of design. Since various pseudo-devices can adopt a unified interface, the upper-layer business module also has good scalability and portability.
最后应当说明的是:以上实施例仅用以说明本发明的技术方案而非对其限制;尽管参照较佳实施例对本发明进行了详细的说明,所属领域的普通技术人员应当理解:依然可以对本发明的具体实施方式进行修改或者对部分技术特征进行等同替换;而不脱离本发明技术方案的精神,其均应涵盖在本发明请求保护的技术方案范围当中。Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit them; although the present invention has been described in detail with reference to the preferred embodiments, those of ordinary skill in the art should understand that: the present invention can still be Modifications to the specific implementation of the invention or equivalent replacement of some technical features; without departing from the spirit of the technical solution of the present invention, should be included in the scope of the technical solution claimed in the present invention.
Claims (10)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CNB2006101619813A CN100428171C (en) | 2006-12-08 | 2006-12-08 | Communication method between data plane and control plane |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CNB2006101619813A CN100428171C (en) | 2006-12-08 | 2006-12-08 | Communication method between data plane and control plane |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN1987798A CN1987798A (en) | 2007-06-27 |
| CN100428171C true CN100428171C (en) | 2008-10-22 |
Family
ID=38184603
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CNB2006101619813A Expired - Fee Related CN100428171C (en) | 2006-12-08 | 2006-12-08 | Communication method between data plane and control plane |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN100428171C (en) |
Families Citing this family (9)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101262501B (en) * | 2008-04-23 | 2011-04-20 | 杭州华三通信技术有限公司 | An inter-core communication method in multi-core system and one multi-core system |
| CN101276289B (en) * | 2008-05-09 | 2010-06-16 | 中兴通讯股份有限公司 | The method of communication between user and multi-core in Linux system |
| US8948084B2 (en) | 2008-05-15 | 2015-02-03 | Telsima Corporation | Systems and methods for data path control in a wireless network |
| EP2277330A4 (en) | 2008-05-15 | 2013-10-09 | Harris Stratex Networks Operat | SYSTEMS AND METHODS FOR ROUTING DISTRIBUTED DATA IN A WIRELESS NETWORK |
| CN102576353A (en) | 2009-05-13 | 2012-07-11 | 航空网络公司 | Systems and methods for fractional routing redundancy |
| SG189130A1 (en) | 2010-09-29 | 2013-05-31 | Aviat Networks Inc | Systems and methods for distributed data routing in a wireless network |
| CN102200930B (en) * | 2011-05-26 | 2013-04-17 | 北京华为数字技术有限公司 | Synchronous variable mapping method and device, synchronous variable freeing method and synchronous variable deleting method |
| CN108632070B (en) * | 2017-03-23 | 2020-04-28 | 华为技术有限公司 | Configuration method and server of virtual network device |
| US11229023B2 (en) * | 2017-04-21 | 2022-01-18 | Netgear, Inc. | Secure communication in network access points |
Citations (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| WO2004001615A1 (en) * | 2002-06-19 | 2003-12-31 | Telefonaktiebolaget Lm Ericsson | A network device driver architecture |
| CN1737780A (en) * | 2004-08-19 | 2006-02-22 | 国际商业机器公司 | System and method for transmitting information from a device drive program to the other |
-
2006
- 2006-12-08 CN CNB2006101619813A patent/CN100428171C/en not_active Expired - Fee Related
Patent Citations (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| WO2004001615A1 (en) * | 2002-06-19 | 2003-12-31 | Telefonaktiebolaget Lm Ericsson | A network device driver architecture |
| CN1737780A (en) * | 2004-08-19 | 2006-02-22 | 国际商业机器公司 | System and method for transmitting information from a device drive program to the other |
Non-Patent Citations (4)
| Title |
|---|
| Linux中用户空间与内核空间的通信实现. 杨宇音,李志淮.微机发展,第15卷第5期. 2005 |
| Linux中用户空间与内核空间的通信实现. 杨宇音,李志淮.微机发展,第15卷第5期. 2005 * |
| 一种高效的用户级通信协议的研究与实现. 李斌,辛海红,胡铭曾.计算机工程,第32卷第1期. 2006 |
| 一种高效的用户级通信协议的研究与实现. 李斌,辛海红,胡铭曾.计算机工程,第32卷第1期. 2006 * |
Also Published As
| Publication number | Publication date |
|---|---|
| CN1987798A (en) | 2007-06-27 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN100428171C (en) | Communication method between data plane and control plane | |
| CN113986515B (en) | Method and device for creating sandbox environment for plug-in operation and computing equipment | |
| US8726295B2 (en) | Network on chip with an I/O accelerator | |
| US7231638B2 (en) | Memory sharing in a distributed data processing system using modified address space to create extended address space for copying data | |
| US20090296685A1 (en) | User-Mode Prototypes in Kernel-Mode Protocol Stacks | |
| WO2024016927A1 (en) | Programmable network element compiling system and compiling method | |
| CN110088737A (en) | Concurrent program is converted to the integration schedules for the hardware that can be deployed in the cloud infrastructure based on FPGA | |
| US9329843B2 (en) | Communication stack for software-hardware co-execution on heterogeneous computing systems with processors and reconfigurable logic (FPGAs) | |
| US8001266B1 (en) | Configuring a multi-processor system | |
| US9069592B2 (en) | Generic transport layer mechanism for firmware communication | |
| CN105389120A (en) | Supporting RMA API over active message | |
| CN119739390B (en) | Method for realizing abstract layer of operating system applied to drive development | |
| US7428730B2 (en) | Software development environment | |
| CN108984324B (en) | FPGA hardware abstraction layer | |
| CN108829530B (en) | Image processing method and device | |
| CN102104508A (en) | M module low-level (LL) driver layer realization method for M module-based local area network (LAN)-based extensions for instrumentation (LXI) equipment | |
| CN110109848A (en) | DSP hardware level of abstraction and dsp processor | |
| CN111666164A (en) | Transaction-level modeling remote method calling method and device | |
| CN117608686A (en) | Accelerator configuration, transmission method, device, equipment, media and server | |
| CN102063113A (en) | Standardized LXI (LAN (Local Area Network) Extension for Instrument) equipment software framework based on M module | |
| CN117009281A (en) | PCIe-based data communication method of FPGA algorithm accelerator | |
| US20200319875A1 (en) | Dynamic runtime programming of hardware tables | |
| US7702764B1 (en) | System and method for testing network protocols | |
| Klingauf et al. | Embedded software development on top of transaction-level models | |
| CN117648211B (en) | AI framework runtime unified interface, server and calling method |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| C06 | Publication | ||
| PB01 | Publication | ||
| C10 | Entry into substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| C14 | Grant of patent or utility model | ||
| GR01 | Patent grant | ||
| CP03 | Change of name, title or address | ||
| CP03 | Change of name, title or address |
Address after: 310052 Binjiang District Changhe Road, Zhejiang, China, No. 466, No. Patentee after: NEW H3C TECHNOLOGIES Co.,Ltd. Address before: 310053 Hangzhou hi tech Industrial Development Zone, Zhejiang province science and Technology Industrial Park, No. 310 and No. six road, HUAWEI, Hangzhou production base Patentee before: HANGZHOU H3C TECHNOLOGIES Co.,Ltd. |
|
| CF01 | Termination of patent right due to non-payment of annual fee | ||
| CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20081022 |