CN112965925B - Communication method, communication device, master equipment and slave equipment - Google Patents

Communication method, communication device, master equipment and slave equipment Download PDF

Info

Publication number
CN112965925B
CN112965925B CN202110291169.7A CN202110291169A CN112965925B CN 112965925 B CN112965925 B CN 112965925B CN 202110291169 A CN202110291169 A CN 202110291169A CN 112965925 B CN112965925 B CN 112965925B
Authority
CN
China
Prior art keywords
application
target channel
channel
control node
communication
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.)
Active
Application number
CN202110291169.7A
Other languages
Chinese (zh)
Other versions
CN112965925A (en
Inventor
王子宜
赵明国
董浩
杨国平
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Youbixuan Intelligent Robot Co ltd
Original Assignee
Ubtech Robotics Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ubtech Robotics Corp filed Critical Ubtech Robotics Corp
Priority to CN202110291169.7A priority Critical patent/CN112965925B/en
Publication of CN112965925A publication Critical patent/CN112965925A/en
Application granted granted Critical
Publication of CN112965925B publication Critical patent/CN112965925B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/382Information transfer, e.g. on bus using universal interface adapter
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/42Bus transfer protocol, e.g. handshake; Synchronisation
    • G06F13/4204Bus transfer protocol, e.g. handshake; Synchronisation on a parallel bus
    • G06F13/4221Bus transfer protocol, e.g. handshake; Synchronisation on a parallel bus being an input/output bus, e.g. ISA bus, EISA bus, PCI bus, SCSI bus
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2213/00Indexing scheme relating to interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F2213/0026PCI express

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer And Data Communications (AREA)
  • Information Transfer Systems (AREA)

Abstract

The application discloses a communication method, a communication device, a master device, a slave device and a computer readable storage medium. Wherein the method comprises the following steps: after the main equipment is started, the first control node and the second control node perform binding operation; when a first control node receives a communication instruction sent by a first application of a main device, determining a first target channel based on the communication instruction, and creating a first virtual node at a driving layer of the main device based on the first target channel; the first control node synchronizes the channel parameters of the first target channel to the second control node, so that the slave device determines a second target channel based on the channel parameters of the first target channel, and creates a second virtual node based on the second target channel; and through the virtual node and the target channel, the communication between the first application and the second application of the slave device is realized. The scheme of the application realizes the dynamic creation of the communication channels of the master equipment and the slave equipment, and reduces the situation of application blocking through reasonable planning of hardware equipment resources.

Description

Communication method, communication device, master equipment and slave equipment
Technical Field
The present application relates to the field of communications technologies, and in particular, to a communications method, a communications apparatus, a master device, a slave device, and a computer readable storage medium.
Background
PCIe (Peripheral Component Interconnect express) is widely used for system expansion and system interconnection as a high-speed serial bus. PCIe extensions can be used as both an implementation of an extended host device and a connection of a master device and a slave device.
Currently, the communication modes of the general PCIe multi-application are as follows: and after the hardware adaptation programs are established in the slave equipment and the master equipment, the hardware adaptation programs at the two ends collect communication data and send the communication data to the opposite ends, and then the hardware adaptation programs at the opposite ends distribute the communication data. In the above manner, since each application needs to distribute communication data through the hardware adaptation program, each application may preempt resources of the hardware adaptation program, which may cause a situation that some applications are blocked. That is, in the prior art, the hardware adaptation program becomes a bottleneck of communication performance.
Disclosure of Invention
The application provides a communication method, a communication device, a master device, a slave device and a computer readable storage medium, which can realize the dynamic creation of a communication channel between the master device and the slave device and reduce the occurrence of application blocking.
In a first aspect, the present application provides a communication method, where the communication method is applied to a master device, including:
after the master device is started, a first control node and a second control node perform binding operation, wherein the first control node is positioned at a driving layer of the master device, and the second control node is positioned at a driving layer of a slave device to be communicated;
when the first control node receives a communication instruction sent by a first application, determining a first target channel based on the communication instruction, and creating a first virtual node at a driving layer of the main device based on the first target channel, wherein the first target channel is an idle channel in the main device, and the first application is an application in the main device;
the first control node synchronizes the channel parameters of the first target channel to the second control node, so that the second control node determines a second target channel based on the channel parameters of the first target channel, and creates a second virtual node at the driving layer of the slave device based on the second target channel, wherein the second target channel is an idle channel in the slave device;
The first application communicates with a second application through the first virtual node, the first target channel, the second virtual node and the second target channel, wherein the second application is an application in a slave device.
In a second aspect, the present application provides a communication method, which is applied to a slave device, including:
after the slave device is started, a first control node and a second control node perform binding operation, wherein the first control node is positioned at a driving layer of a master device to be communicated, and the second control node is positioned at the driving layer of the slave device;
when the second control node receives the channel parameter of the first target channel sent by the first control node, determining a second target channel based on the channel parameter of the first target channel, and creating a second virtual node at the driving layer of the slave device based on the second target channel;
and the second application communicates with the first application through the first virtual node, the first target channel, the second virtual node and the second target channel, wherein the first application is an application in the master device, the second application is an application in the slave device, and the first virtual node is a virtual node created based on the first target channel in the master device.
In a third aspect, the present application provides a communication apparatus, which is applied to a master device, including:
the first binding unit is used for carrying out binding operation on a first control node and a second control node after the main equipment is started, wherein the first control node is positioned at a driving layer of the main equipment, and the second control node is positioned at a driving layer of a slave equipment to be communicated;
the first determining unit is configured to determine a first target channel based on a communication instruction sent by a first application when the first control node receives the communication instruction, where the first target channel is an idle channel in the master device, and the first application is an application in the master device;
a first creating unit, configured to create a first virtual node at a driving layer of the master device based on the first target channel;
the synchronization unit is configured to synchronize, by the first control node, a channel parameter of the first target channel to the second control node, so that the second control node determines a second target channel based on the channel parameter of the first target channel, and creates a second virtual node at a driving layer of the slave device based on the second target channel, where the second target channel is an idle channel in the slave device;
The first communication unit is configured to communicate with a second application through the first virtual node, the first target channel, the second virtual node, and the second target channel, where the second application is an application in a slave device.
In a fourth aspect, the present application provides a communication apparatus, the communication apparatus being applied to a slave device, comprising:
the second binding unit is used for carrying out binding operation on the first control node and the second control node after the slave device is started, wherein the first control node is positioned at the driving layer of the master device to be communicated, and the second control node is positioned at the driving layer of the slave device;
a second determining unit, configured to determine, when the second control node receives a channel parameter of a first target channel sent by the first control node, a second target channel based on the channel parameter of the first target channel;
a second creating unit, configured to create a second virtual node at a driving layer of the slave device based on the second target channel;
and the second communication unit is used for communicating with a first application through a first virtual node, the first target channel, the second virtual node and the second target channel, wherein the first application is an application in the master device, the second application is an application in the slave device, and the first virtual node is a virtual node created based on the first target channel in the master device.
In a fifth aspect, the present application provides a host device comprising a first memory, a first processor and a first computer program stored in said first memory and executable on said first processor, characterized in that said first processor implements the steps of the method according to the first aspect when executing said first computer program.
In a sixth aspect, the present application provides a slave device comprising a second memory, a second processor and a second computer program stored in said second memory and executable on said second processor, characterized in that said second processor implements the steps of the method according to the second aspect when executing said second computer program.
In a seventh aspect, the present application provides a computer readable storage medium storing a computer program which, when executed by a processor, performs the steps of the method of the first aspect; alternatively, the computer program, when executed by a processor, implements the steps of the method of the second aspect
In an eighth aspect, the present application provides a computer program product comprising a computer program which, when executed by one or more processors, implements the steps of the method of the first aspect as described above; alternatively, the computer program described above, when executed by one or more processors, implements the steps of the method of the second aspect described above.
Compared with the prior art, the application has the beneficial effects that: firstly, after the master device is started, a first control node and a second control node perform binding operation, wherein the first control node is located at a driving layer of the master device, the second control node is located at a driving layer of a slave device to be communicated, when the first control node receives a communication instruction sent by a first application, a first target channel is determined based on the communication instruction, a first virtual node is created based on the first target channel at the driving layer of the master device, the first target channel is an idle channel in the master device, the first application is an application in the master device, then the first control node synchronizes channel parameters of the first target channel to the second control node, so that the second control node determines a second target channel based on the channel parameters of the first target channel, and creates a second virtual node based on the second target channel at the driving layer of the slave device, wherein the second target channel is the idle channel in the slave device, the first application is the application in the master device, and finally the first control node is the first application, the second control node is the slave device, and the first application is the second application. The scheme of the application establishes the control node in the driving layer of the master device and the driving layer of the slave device, and applies for establishing the virtual node to the control node of the master device by the application of the master device, wherein the virtual node is used for providing a communication channel, and meanwhile, the channel parameters of the channel provided by the virtual node are synchronized to the slave device, so that the slave device can also establish the corresponding virtual node, and thus, the application of the master device and the application of the slave device can carry out direct communication through the virtual nodes respectively established, the process realizes the dynamic establishment of the communication channels of the master device and the slave device, and reduces the occurrence of application blocking through reasonable planning of hardware device resources. It will be appreciated that the advantages of the second to eighth aspects may be found in the relevant description of the first aspect, and are not repeated here.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the embodiments or the description of the prior art will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings can be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a schematic diagram of an implementation flow of a communication method according to an embodiment of the present application;
FIG. 2 is a schematic flow chart of another implementation of a communication method according to an embodiment of the present application;
FIG. 3 is a block diagram of a communication system provided by an embodiment of the present application;
FIG. 4 is a schematic diagram illustrating the operation of a PCIe master device and a PCIe slave device in a first stage provided by an embodiment of the present application;
FIG. 5 is a schematic diagram illustrating the operation of a PCIe master device and a PCIe slave device in a second stage provided by an embodiment of the present application;
FIG. 6 is a schematic diagram illustrating operations of a PCIe master device and a PCIe slave device in a third stage provided by an embodiment of the present application;
FIG. 7 is a schematic diagram illustrating operations of a PCIe master device and a PCIe slave device in a fourth stage provided by an embodiment of the present application;
FIG. 8 is a schematic diagram illustrating the operation of a PCIe master device and a PCIe slave device in a fifth stage provided by an embodiment of the present application;
Fig. 9 is a schematic structural diagram of a communication device according to an embodiment of the present application;
fig. 10 is a schematic structural diagram of another communication device according to an embodiment of the present application;
FIG. 11 is a schematic diagram of a master device according to an embodiment of the present application
Fig. 12 is a schematic structural diagram of a slave device according to an embodiment of the present application.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth such as the particular system architecture, techniques, etc., in order to provide a thorough understanding of the embodiments of the present application. It will be apparent, however, to one skilled in the art that the present application may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
In order to illustrate the technical scheme provided by the application, the following description is made by specific embodiments.
The following describes a communication method provided by the embodiment of the present application, where the communication method provided by the embodiment of the present application is applied to PCIe master devices. Referring to fig. 1, the communication method includes:
step 101, after the master device is started, the first control node and the second control node perform a binding operation.
In the embodiment of the present application, after the PCIe Master device is started, the PICe Master device may establish a control node PDM (pcie_driver_master) in its driving layer. And, after the PCIe Slave device is started, the PICe Slave device may also establish a control node PDS (pcie_driver_slave) in its Driver layer. For distinction, the present embodiment refers to the PDM as a first control node and the PDS as a second control node. After the PCIe master device and the PCIe slave device are started, the first control node can perform binding operation with the second control node, wherein the first control node specifically executes the binding operation under the instruction of a bind instruction, and the second control node specifically executes the binding operation under the instruction of a probe instruction. Through the binding operation, the PCIe master device and the PCIe slave device respectively perform a series of binding flows such as address space mapping of corresponding base address registers (Base Address Register, BAR), MSI (Message Signaled Interrupts) interrupt application, and the like. Wherein BAR0 acts as a command channel and MSI0 acts as a command interrupt.
In some embodiments, after the PCIe master device is booted, the first address space is also applied for BAR1 of the PCIe master device in its kernel space. To distinguish from BAR1 of a PCIe slave device, embodiments of the present application record BAR1 of a PCIe master device as a first base address register. It should be noted that since BAR1 is ready for communication between the application of the subsequent PCIe master device and the application of the PCIe slave device, the first address space should be large, e.g., the first address space may be set to be larger than a preset size.
Step 102, when the first control node receives a communication instruction sent by a first application, determining a first target channel based on the communication instruction, and creating a first virtual node at a driving layer of the master device based on the first target channel.
In the embodiment of the application, when the first control node receives a communication instruction sent by an application of the PCIe master device, the driving layer may be operated according to the communication instruction. For ease of illustration, the application in the PCIe master device that sends the communication instructions may be referred to as a first application. The first control node responds to a communication instruction sent by the first application, determines a channel in the idle channel as a first target channel, and creates a virtual node pcie_master_dev1 in a driving layer of the PCIe main device based on the first target channel. For ease of illustration, this virtual node pcie_master_dev1 may be referred to as the first virtual node. It can be considered that a virtual node is a virtual device created in a physical device, which occupies a channel; that is, the first virtual node occupies the first target channel, and functions as: communication with other virtual nodes is achieved through the first target channel.
In some embodiments, the PCIe host device may specifically look up an empty address space in its BAR1 address space (i.e., the first address space) as the first target channel based on the communication instruction sent by the first application. Illustratively, the communication instructions carry the following information: channel name, channel buffer space size, number of terminals associated with the channel, channel rights, etc. And determining a corresponding first target channel for the first application based on the information carried by the channel instruction, so that the channel parameters of the first target channel are matched with the information carried by the communication instruction.
In some embodiments, the PCIe host device also creates a service program PDMD in its user space. For ease of description, the service program PDMD may be referred to as a first service program. The first service program can be used as an interaction bridge between the first application and the first control node; that is, the first application may actually perform a direct data interaction with the first service program, for example, the first application may send a communication instruction to the first service program through a message queue, and then the first server program forwards the communication instruction to a first control node of the driver layer through an input/output control unit (ioctl) to trigger the first control node to determine a first target channel and create a first virtual node based on the communication instruction.
In some embodiments, after applying for the first address space for the first base address register, the PCIe master device may further initialize a first channel linked list based on the first address space, where the first channel linked list is used to store channel parameters of channels that have been used in the first address space. Obviously, when the first channel linked list is just initialized, no used channel exists yet, and thus, the first channel linked list obtained by initialization is empty. After the first target channel is determined based on the communication instruction, the first channel linked list can be updated based on the first target channel. That is, the first channel linked list is updated whenever the channel state changes, for example, from an idle state to an occupied state, or from an occupied state to an idle state.
Step 103, the first control node synchronizes the channel parameter of the first target channel to the second control node, so that the second control node determines a second target channel based on the channel parameter of the first target channel, and creates a second virtual node at the driving layer of the slave device based on the second target channel.
In the embodiment of the application, the first control node also notifies the second control node of the channel parameters of the first target channel through the internal interrupt and the internal instruction of PCIe, so as to realize the synchronization of the channel parameters of the first target channel. After receiving the channel parameters of the first target channel, the second control node searches an idle address space in a second address space to serve as a second target channel, wherein the channel parameters of the second target channel are consistent with the channel parameters of the first target channel, that is, the channel name, the channel cache space size, the number of terminals associated with the channel, the channel authority and the like of the second target channel are the same as those of the first target channel. And the PCIe slave device also creates a virtual node pcie_slave_dev1 at a driver layer of the PCIe slave device based on the second target channel. For ease of illustration, the virtual node pcie_slave_dev1 may be referred to as a second virtual node. That is, the second virtual node occupies the second target channel, and functions as: communication with the first virtual node is achieved through the second target channel. Thus, the first virtual node and the second virtual node can perform direct communication.
Step 104, the first application communicates with a second application through the first virtual node, the first target channel, the second virtual node, and the second target channel.
In the embodiment of the application, the first control node packages the created information of the first virtual node and the channel parameters of the channel corresponding to the first virtual node (i.e. the channel parameters of the first target channel) as the created information, and returns the created information to the first service program; the first application can thus obtain the creation information of this time through interaction with the first service program. Because the first virtual node and the second virtual node can perform direct communication, the first application can communicate with the second application through the first virtual node, the first target channel, the second virtual node and the second target channel, wherein the second application refers to application in the PCIe slave device.
In the embodiment of the application, control nodes are established in the driving layer of the master device and the driving layer of the slave device, and the application of the master device applies for creating virtual nodes to the control nodes of the master device, wherein the virtual nodes serve as channels for providing communication, and meanwhile, the information of the channels provided by the virtual nodes can be synchronized to the slave device, so that the slave device can also create corresponding virtual nodes, and thus, the application of the master device and the application of the slave device can carry out direct communication through the virtual nodes respectively created, the process realizes the dynamic creation of the communication channels of the master device and the slave device, and the situation of application blocking is reduced through reasonable planning of hardware device resources.
The following describes a communication method provided by the embodiment of the present application, where the communication method provided by the embodiment of the present application is applied to PCIe slave devices. Referring to fig. 2, the communication method includes:
step 201, after the slave device is started, the first control node and the second control node perform a binding operation.
In the embodiment of the application, after the PCIe slave device is started, the PICe slave device may establish a control node PDS in its driving layer. And, after the PCIe master device is started, the PICe master device may also establish a control node PDM in its driver layer. For distinction, the present embodiment refers to the PDM as a first control node and the PDS as a second control node. After the PCIe master device and the PCIe slave device are started, the first control node can perform binding operation with the second control node, wherein the first control node specifically executes the binding operation under the instruction of a bind instruction, and the second control node specifically executes the binding operation under the instruction of a probe instruction. Through the binding operation, the PCIe master device and the PCIe slave device respectively perform a series of binding flows such as corresponding BAR address space mapping, MSI interrupt application and the like. Wherein BAR0 acts as a command channel and MSI0 acts as a command interrupt.
In some embodiments, after the PCIe slave device is booted, a second address space is also applied for BAR1 of the PCIe slave device in its kernel space. To distinguish from BAR1 of the PCIe master device, embodiments of the present application record BAR1 of the PCIe slave device as the second base address register. It should be noted that since BAR1 is ready for communication between the application of the subsequent PCIe slave device and the application of the PCIe master device, the second address space should be large, e.g., the second address space may be set to be larger than a preset size.
Step 202, when the second control node receives the channel parameter of the first target channel sent by the first control node, determining a second target channel based on the channel parameter of the first target channel, and creating a second virtual node at the driving layer of the slave device based on the second target channel.
In the embodiment of the application, when the second control node receives the channel parameter of the first target channel sent by the first control node, the second control node can know that the application in the current PCIe main device is applying for creating the channel to communicate, so that the second control node can operate the driving layer according to the channel parameter of the first target channel. For ease of illustration, the application in the PCIe master device that is applying for creation of a lane (i.e., sending a communication instruction) may be referred to as a first application. The PCIe slave device can know that the first target channel is the channel obtained by the PCIe master device responding to the communication instruction, based on the first target channel, the second control node also responds to the channel parameter of the first target channel, determines a second target channel in the idle channel, and creates a virtual node pcie_slave_dev1 in the driving layer of the PCIe slave device based on the second target channel. For ease of illustration, the virtual node pcie_slave_dev1 may be referred to as a second virtual node. That is, the second virtual node occupies the second target channel, and functions as: communication with other virtual nodes (e.g., the first virtual node of the PCIe master device) is achieved through the second target lane.
In some embodiments, the PCIe slave device may specifically look up an empty address space in its BAR1 address space (i.e., the second address space) as the second target channel based on the channel parameters of the second target channel. Illustratively, the channel parameters include the following data: channel name, channel buffer space size, number of terminals associated with the channel, channel rights, etc. Therefore, the channel parameters of the second target channel are consistent with the channel parameters of the first target channel, that is, the channel name, the channel buffer space size, the number of terminals associated with the channel, the channel rights, and the like of the second target channel are the same as those of the first target channel.
In some embodiments, the PCIe slave device also creates a service program PDSD in its user space. For ease of illustration, the service PDSD may be referred to as a second service. The second service may act as an interactive bridge for applications in PCIe with the second control node. For ease of illustration, the application in the PCIe slave device may be referred to as a second application. That is, the second application is actually a direct data interaction with the second service program.
In some embodiments, after applying for the second address space for the second base address register, the PCIe master device may further initialize a second channel linked list based on the second address space, where the second channel linked list is used to store channel parameters of channels that have been used in the second address space. Obviously, when the second channel linked list is just initialized, no used channel exists yet, and thus, the initialized second channel linked list is empty. After determining the second target channel based on the channel parameters of the first target channel, the second channel linked list can be updated based on the second target channel. That is, the second channel linked list is updated whenever the channel state changes, for example, from an idle state to an occupied state, or from an occupied state to an idle state.
In step 203, the second application communicates with the first application through the first virtual node, the first target channel, the second virtual node, and the second target channel.
In the embodiment of the application, since the second application performs direct data interaction with the second service program, the second application can send a query instruction to the second service program, so that the second service program queries and reports the channel parameters of the second target channel and the information of the second virtual node which are currently created through the second control node, and the second application knows the channel parameters and the information of the second virtual node. Because the first virtual node and the second virtual node can perform direct communication, the second application can communicate with the first application through the first virtual node, the first target channel, the second virtual node and the second target channel.
In the embodiment of the application, control nodes are established in the driving layer of the master device and the driving layer of the slave device, and the application of the master device applies for creating virtual nodes to the control nodes of the master device, wherein the virtual nodes serve as channels for providing communication, and meanwhile, the information of the channels provided by the virtual nodes can be synchronized to the slave device, so that the slave device can also create corresponding virtual nodes, and thus, the application of the master device and the application of the slave device can carry out direct communication through the virtual nodes respectively created, the process realizes the dynamic creation of the communication channels of the master device and the slave device, and the situation of application blocking is reduced through reasonable planning of hardware device resources.
The following describes a communication method provided by the embodiment of the present application, where the communication method provided by the embodiment of the present application is applied to a communication system, and please refer to fig. 3, where the communication system is composed of a PCIe master device and a PCIe slave device. Taking various stages in the communication process as an example, the working process of the PCIe master device and the PCIe slave device is described below:
referring to fig. 4, first, a first control node PDM is established in a driving layer of a PCIe master device, and a second control node PDS is established in a driving layer of a PCIe slave device. And the PCIe master device and the PCIe slave device start up to perform binding operation, and perform corresponding BAR address space mapping and MSI interrupt application. On this basis, the PCIe master device and the PCIe slave device also respectively establish respective channel linked lists, which are the first channel linked list and the second channel linked list respectively.
Referring to fig. 5, the user space of the PCIe master device further creates a first service program PDMD, and the user space of the PCIe slave device further creates a second service program PDSD.
Referring to fig. 6, then, the application of the PCIe master device (i.e., the first application APP 1) may send a communication instruction to the PDM through the PDMD, where the communication instruction carries a channel name, a channel cache space size, a number of terminals associated with the channel, and a channel authority. In fig. 6, the communication instruction is represented as:
Request_Channel(
Name:test
endpointNum:2
Buf:4K
Mode:660)
Wherein Name is the channel Name; buf is the channel buffer space size; the endpoint num is the number of terminals associated with the channel; mode is channel authority.
The channel parameters of the first target channel obtained based on the communication instruction are as follows:
Name:test
endpointNum:2
Buf:1K-5K
MSI:1
Mode:660
wherein, buf:1K-5K indicates that the address space occupied by the channel is 1K to 5K, namely the size of the channel buffer space is 5K-1 K=4K. MSI:1 indicates that the MSI interrupt it occupies is MSI1, represented in FIG. 6 by the arrow pointing to MSI 1.
Therefore, the PDM applies for the corresponding idle address space as a first target channel in the first address space based on the communication instruction, and updates the channel parameters of the first target channel into a first channel linked list.
The channel parameters of the first target channel are synchronized to the PCIe slave device, so that the PCIe slave device applies for a corresponding idle address space in the second address space based on the channel parameters of the first target channel as a second target channel, and updates the channel parameters of the second target channel into the second channel linked list.
Referring to fig. 7, finally, the PCIe master device establishes a first virtual node pcie_master_dev1 based on the first target channel; the PCIe slave device establishes a second virtual node pcie_slave_dev1 based on the second target lane. The PDMD may send the information of the first virtual node and the channel parameter of the first target channel acquired from the PDM to the first application APP1 as the creation information; the second application APP2 may send a query instruction to the PDSD, so that the PDSD queries, through the PDS, the channel parameter of the second target channel and the information of the second virtual node, where the PDSD reports the query result to the second application APP2.
Referring to fig. 8, the first application APP1 may implement direct communication with the second application APP2 through the first target channel, the second target channel, the first virtual node pcie_master_dev1, and the second virtual node pcie_slave_dev1.
It will be appreciated that based on the above process, multiple PCIe direct lanes may be created between one PCIe master device and one PCIe slave device for communication between different application groups; that is, different application groups can adopt different virtual nodes and channels for communication, so that mutual isolation among the application groups is realized, and the safety is higher. In addition, one application in the PCIe master device can communicate with a plurality of applications in the PCIe slave device based on the same channel, namely, the communication method provided by the embodiment of the application also supports one-to-many application scenes, and has higher flexibility.
In the embodiment of the application, control nodes are established in the driving layer of the master device and the driving layer of the slave device, and the application of the master device applies for creating virtual nodes to the control nodes of the master device, wherein the virtual nodes serve as channels for providing communication, and meanwhile, the information of the channels provided by the virtual nodes can be synchronized to the slave device, so that the slave device can also create corresponding virtual nodes, and thus, the application of the master device and the application of the slave device can carry out direct communication through the virtual nodes respectively created, the process realizes the dynamic creation of the communication channels of the master device and the slave device, and the situation of application blocking is reduced through reasonable planning of hardware device resources. In addition, the communication between the master device and the slave device only involves two times of data transmission in the kernel space and the user space, so that the data transmission speed can be improved to a certain extent. Furthermore, when the channel is created, the authority of the channel can be customized, so that the security management is facilitated.
Corresponding to the communication method applied to the master device provided in the foregoing, the embodiment of the present application provides a communication apparatus, where the communication apparatus is applied to the master device, as shown in fig. 9, a communication apparatus 900 in the embodiment of the present application includes:
a first binding unit 901, configured to perform a binding operation between a first control node and a second control node after the master device is started, where the first control node is located at a driving layer of the master device, and the second control node is located at a driving layer of a slave device to be communicated;
a first determining unit 902, configured to determine, when the first control node receives a communication instruction sent by a first application, based on the communication instruction, a first target channel, where the first target channel is an idle channel in the master device, and the first application is an application in the master device;
a first creating unit 903, configured to create a first virtual node at a driving layer of the master device based on the first target channel;
a synchronization unit 904, configured to synchronize, by the first control node, a channel parameter of the first target channel to the second control node, so that the second control node determines a second target channel based on the channel parameter of the first target channel, and creates a second virtual node at a driving layer of the slave device based on the second target channel, where the second target channel is an idle channel in the slave device;
A first communication unit 905, configured to communicate with a second application through the first virtual node, the first target channel, the second virtual node, and the second target channel, where the second application is an application in a slave device.
Optionally, the communication device 900 further includes:
a first address space applying unit, configured to apply, in a kernel space of the master device, a first address space for a first base address register, where the first base address register is a base address register preset in the master device, and the first address space is greater than a preset size;
accordingly, the first determining unit 902 is specifically configured to search, based on the communication instruction, an empty address space in the first address space as the first target channel.
Optionally, the communication device 900 further includes:
a first channel chain initializing unit, configured to initialize a first channel linked list based on the first address space, where the first channel linked list is used to store channel parameters of channels that have been used in the first address space;
and the first channel chain updating unit is used for updating the first channel linked list based on the first target channel.
Optionally, the communication device 900 further includes:
a first service program creation unit configured to create a first service program in a user space of the master device;
and the instruction sending unit is used for sending a communication instruction to the first control node by the first application through the first server program.
In the embodiment of the application, control nodes are established in the driving layer of the master device and the driving layer of the slave device, and the application of the master device applies for creating virtual nodes to the control nodes of the master device, wherein the virtual nodes serve as channels for providing communication, and meanwhile, the information of the channels provided by the virtual nodes can be synchronized to the slave device, so that the slave device can also create corresponding virtual nodes, and thus, the application of the master device and the application of the slave device can carry out direct communication through the virtual nodes respectively created, the process realizes the dynamic creation of the communication channels of the master device and the slave device, and the situation of application blocking is reduced through reasonable planning of hardware device resources.
Corresponding to the communication method provided in the foregoing and applied to the slave device, the embodiment of the present application provides a communication apparatus, where the communication apparatus is applied to the slave device, as shown in fig. 10, a communication apparatus 1000 in the embodiment of the present application includes:
A second binding unit 1001, configured to perform a binding operation between a first control node and a second control node after the slave device is started, where the first control node is located at a driving layer of a master device to be communicated, and the second control node is located at a driving layer of the slave device;
a second determining unit 1002, configured to determine, when the second control node receives the channel parameter of the first target channel sent by the first control node, a second target channel based on the channel parameter of the first target channel;
a second creating unit 1003, configured to create a second virtual node at a driving layer of the slave device based on the second target channel;
and a second communication unit 1004, configured to communicate with a first application through a first virtual node, the first target channel, the second virtual node, and the second target channel, where the first application is an application in the master device, the second application is an application in the slave device, and the first virtual node is a virtual node created based on the first target channel in the master device.
Optionally, the communication device 1000 further includes:
A second address space applying unit, configured to apply a second address space for a second base address register in the kernel space of the slave device, where the second base address register is a base address register preset in the slave device, and the second address space is greater than a preset size;
accordingly, the second determining unit 1002 is specifically configured to search for an empty address space in the second address space as the second target channel based on the channel parameter of the first target channel.
Optionally, the communication device 1000 further includes:
a second channel chain initializing unit, configured to initialize a second channel linked list based on the second address space, where the second channel linked list is used to store channel parameters of channels that have been used in the second address space;
and the second channel chain updating unit is used for updating the second channel linked list based on the second target channel.
Optionally, the communication device 1000 further includes:
a second service program creation unit configured to create a second service program in a user space of the slave device;
and the reporting unit is used for inquiring the information of the second virtual node and the channel parameters of the second target channel after the second service program receives the inquiry command sent by the second application, and reporting the information of the second virtual node and the channel parameters of the second target channel to the second application.
In the embodiment of the application, control nodes are established in the driving layer of the master device and the driving layer of the slave device, and the application of the master device applies for creating virtual nodes to the control nodes of the master device, wherein the virtual nodes serve as channels for providing communication, and meanwhile, the information of the channels provided by the virtual nodes can be synchronized to the slave device, so that the slave device can also create corresponding virtual nodes, and thus, the application of the master device and the application of the slave device can carry out direct communication through the virtual nodes respectively created, the process realizes the dynamic creation of the communication channels of the master device and the slave device, and the situation of application blocking is reduced through reasonable planning of hardware device resources.
In response to the foregoing communication method applied to the master device, the embodiment of the present application provides a master device, referring to fig. 11, the master device 11 in the embodiment of the present application includes: a first memory 1101, one or more first processors 1102 (only one shown in fig. 11) and a first computer program stored on the first memory 1101 and executable on the first processors. Wherein: the first memory 1101 is configured to store software programs and modules, and the first processor 1102 executes various functional applications and data processing by running the software programs and units stored in the first memory 1101 to obtain resources corresponding to preset events. Specifically, the first processor 1102 may implement steps in a communication method applied to a master device, such as steps 101 to 104 shown in fig. 1, by executing the above-mentioned first computer program stored in the first memory 1101, which is not described herein.
It should be appreciated that in embodiments of the present application, the first processor 1102 may be a central processing unit (Central Processing Unit, CPU), the first processor 1102 may also be other general purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), off-the-shelf programmable gate arrays (Field-Programmable Gate Arra, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. The general purpose processor may be a microprocessor, or may be any conventional processor or the like.
The first memory 1101 may include read only memory and random access memory and provide instructions and data to the first processor 1102. Part or all of the first memory 1101 may also include a nonvolatile random access memory. For example, the first memory 1101 may also store information of a device class.
Corresponding to the communication method provided in the foregoing and applied to the slave device, the embodiment of the present application provides a slave device, referring to fig. 12, the slave device 12 in the embodiment of the present application includes: a second memory 1201, one or more second processors 1202 (only one shown in fig. 12) and a second computer program stored on the second memory 1201 and executable on the second processors. Wherein: the second memory 1201 is used for storing software programs and modules, and the second processor 1202 executes various functional applications and data processing by running the software programs and units stored in the second memory 1201 to acquire resources corresponding to preset events. Specifically, the second processor 1202 may implement steps in the communication method applied to the slave device, such as steps 201 to 203 shown in fig. 2, by executing the above-mentioned second computer program stored in the second memory 1201, which will not be described herein.
It should be appreciated that in an embodiment of the application, the second processor 1202 may be a central processing unit (Central Processing Unit, CPU), the second processor 1202 may also be other general purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), off-the-shelf programmable gate arrays (Field-Programmable Gate Arra, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. A general purpose processor may be a microprocessor, or may be any conventional processor or the like.
The second memory 1201 may include read only memory and random access memory, and provide instructions and data to the second processor 1202. Part or all of the second memory 1201 may also include a nonvolatile random access memory. For example, the second memory 1201 may also store information of a device class.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-described division of the functional units and modules is illustrated, and in practical application, the above-described functional distribution may be performed by different functional units and modules according to needs, i.e. the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-described functions. The functional units and modules in the embodiment may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit, where the integrated units may be implemented in a form of hardware or a form of a software functional unit. In addition, the specific names of the functional units and modules are only for distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working process of the units and modules in the above system may refer to the corresponding process in the foregoing method embodiment, which is not described herein again.
In the foregoing embodiments, the descriptions of the embodiments are emphasized, and in part, not described or illustrated in any particular embodiment, reference is made to the related descriptions of other embodiments.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or combinations of external device software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other manners. For example, the system embodiments described above are merely illustrative, e.g., the division of modules or units described above is merely a logical functional division, and there may be additional divisions when actually implemented, e.g., multiple units or components may be combined or integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection via interfaces, devices or units, which may be in electrical, mechanical or other forms.
The units described above as separate components may or may not be physically separate, and components shown as units may or may not be physical units, may be located in one place, or may be distributed over a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
The integrated units described above, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the present application may also be implemented by implementing all or part of the flow of the method of the above embodiment, or by instructing the associated hardware by a computer program, where the computer program may be stored on a computer readable storage medium, and where the computer program, when executed by a processor, may implement the steps of each of the method embodiments described above. The computer program comprises computer program code, and the computer program code can be in a source code form, an object code form, an executable file or some intermediate form and the like. The above computer readable storage medium may include: any entity or device capable of carrying the computer program code described above, a recording medium, a U disk, a removable hard disk, a magnetic disk, an optical disk, a computer readable Memory, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), an electrical carrier wave signal, a telecommunications signal, a software distribution medium, and so forth. It should be noted that the content of the computer readable storage medium described above may be appropriately increased or decreased according to the requirements of the jurisdiction's legislation and the patent practice, for example, in some jurisdictions, the computer readable storage medium does not include electrical carrier signals and telecommunication signals according to the legislation and the patent practice.
The above embodiments are only for illustrating the technical solution of the present application, and are not limiting; although the application has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present application, and are intended to be included in the scope of the present application.

Claims (10)

1. A communication method, wherein the communication method is applied to a master device, and comprises:
after the master device is started, a first control node and a second control node perform binding operation, wherein the first control node is positioned at a driving layer of the master device, and the second control node is positioned at a driving layer of a slave device to be communicated;
when the first control node receives a communication instruction sent by a first application, determining a first target channel based on the communication instruction, and creating a first virtual node at a driving layer of the main equipment based on the first target channel, wherein the first target channel is an idle channel in the main equipment, and the first application is an application in the main equipment;
The first control node synchronizes the channel parameters of the first target channel to the second control node, so that the second control node determines a second target channel based on the channel parameters of the first target channel, and creates a second virtual node at the driving layer of the slave device based on the second target channel, wherein the second target channel is an idle channel in the slave device;
the first application communicates with a second application through the first virtual node, the first target channel, the second virtual node and the second target channel, wherein the second application is an application in the slave device.
2. The communication method of claim 1, wherein after the master device is booted, the communication method further comprises:
applying a first address space for a first base address register in a kernel space of the main equipment, wherein the first base address register is a base address register preset in the main equipment, and the first address space is larger than a preset size;
accordingly, the determining the first target channel based on the communication instruction includes:
and searching an idle address space in the first address space as a first target channel based on the communication instruction.
3. The communication method of claim 2, wherein after applying for the first address space for the first base address register in the kernel space of the master device, the communication method further comprises:
initializing a first channel linked list based on the first address space, wherein the first channel linked list is used for storing channel parameters of channels used in the first address space;
accordingly, after the determining the first target channel based on the communication instruction, the communication method further includes:
and updating the first channel linked list based on the first target channel.
4. The communication method of claim 1, wherein before the first control node receives the communication instruction sent by the first application, the communication method further comprises:
creating a first service program in a user space of the master device;
the first application sends a communication instruction to the first control node through the first server program.
5. A communication method, wherein the communication method is applied to a slave device, comprising:
after the slave device is started, a first control node and a second control node perform binding operation, wherein the first control node is positioned at a driving layer of a master device to be communicated, and the second control node is positioned at the driving layer of the slave device;
When the second control node receives the channel parameter of the first target channel sent by the first control node, determining a second target channel based on the channel parameter of the first target channel, and creating a second virtual node at the driving layer of the slave device based on the second target channel;
the second application is communicated with a first application through a first virtual node, the first target channel, the second virtual node and the second target channel, wherein the first application is an application in the master device, the second application is an application in the slave device, and the first virtual node is a virtual node created based on the first target channel in the master device.
6. A communication apparatus, the communication apparatus being applied to a host device, comprising:
the first binding unit is used for carrying out binding operation on a first control node and a second control node after the main equipment is started, wherein the first control node is positioned at a driving layer of the main equipment, and the second control node is positioned at a driving layer of a slave equipment to be communicated;
the first determining unit is used for determining a first target channel based on a communication instruction sent by a first application when the first control node receives the communication instruction, wherein the first target channel is an idle channel in the main equipment, and the first application is an application in the main equipment;
The first creating unit is used for creating a first virtual node at a driving layer of the main equipment based on the first target channel;
the synchronization unit is used for synchronizing the channel parameters of the first target channel to the second control node by the first control node, so that the second control node determines a second target channel based on the channel parameters of the first target channel and creates a second virtual node at the driving layer of the slave device based on the second target channel, wherein the second target channel is an idle channel in the slave device;
the first communication unit is used for the first application to communicate with a second application through the first virtual node, the first target channel, the second virtual node and the second target channel, wherein the second application is an application in the slave device.
7. A communication apparatus, the communication apparatus being applied to a slave device, comprising:
the second binding unit is used for carrying out binding operation on the first control node and the second control node after the slave device is started, wherein the first control node is positioned at a driving layer of the master device to be communicated, and the second control node is positioned at the driving layer of the slave device;
A second determining unit, configured to determine, when the second control node receives a channel parameter of a first target channel sent by the first control node, a second target channel based on the channel parameter of the first target channel;
a second creating unit, configured to create a second virtual node at a driving layer of the slave device based on the second target channel;
the second communication unit is used for communicating with a first application through a first virtual node, the first target channel, the second virtual node and the second target channel, wherein the first application is an application in the master device, the second application is an application in the slave device, and the first virtual node is a virtual node created based on the first target channel in the master device.
8. A host device comprising a first memory, a first processor and a first computer program stored in the first memory and executable on the first processor, wherein the first processor implements the method of any of claims 1 to 4 when executing the first computer program.
9. A slave device comprising a second memory, a second processor and a second computer program stored in the second memory and executable on the second processor, wherein the second processor implements the method of claim 5 when executing the second computer program.
10. A computer readable storage medium storing a computer program, characterized in that the computer program when executed by a processor implements the method of any one of claims 1 to 4; alternatively, the computer program, when executed by a processor, implements the method of any of claims 5.
CN202110291169.7A 2021-03-18 2021-03-18 Communication method, communication device, master equipment and slave equipment Active CN112965925B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110291169.7A CN112965925B (en) 2021-03-18 2021-03-18 Communication method, communication device, master equipment and slave equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110291169.7A CN112965925B (en) 2021-03-18 2021-03-18 Communication method, communication device, master equipment and slave equipment

Publications (2)

Publication Number Publication Date
CN112965925A CN112965925A (en) 2021-06-15
CN112965925B true CN112965925B (en) 2023-09-22

Family

ID=76279253

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110291169.7A Active CN112965925B (en) 2021-03-18 2021-03-18 Communication method, communication device, master equipment and slave equipment

Country Status (1)

Country Link
CN (1) CN112965925B (en)

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10067900B2 (en) * 2015-08-25 2018-09-04 Oracle International Corporation Virtualized I/O device sharing within a distributed processing node system
CN109213702B (en) * 2017-06-30 2022-08-30 伊姆西Ip控股有限责任公司 Communication between virtual dual control modules in a virtual machine environment

Also Published As

Publication number Publication date
CN112965925A (en) 2021-06-15

Similar Documents

Publication Publication Date Title
CN100382069C (en) Apparatus and method for sharing a network I/O adapter between logical partitions
KR102184512B1 (en) Management method and device
CN110119304B (en) Interrupt processing method and device and server
JP2021503124A (en) Acceleration resource scheduling method and equipment, and acceleration system
CN115858103B (en) Method, device and medium for virtual machine hot migration of open stack architecture
CN110389711B (en) Method, device, and non-transitory computer-readable medium for assisting endpoint device in implementing SR-IOV functionality
EP3908928A1 (en) Low-latency events across a virtual machine boundary
JP6448012B2 (en) Method, apparatus, and system for displaying virtual machine names
CN111813459A (en) Accelerator loading method and system and accelerator loading device
CN112965925B (en) Communication method, communication device, master equipment and slave equipment
CN113132356A (en) UDP (user Datagram protocol) message distribution method, equipment and storage medium
KR20190044098A (en) Method and device for use in accessing a container
CN109582242B (en) Address determination method and device for cascade memory array system and electronic equipment
US20230019037A1 (en) Reactive non-blocking input and output for target device communication
WO2012079371A1 (en) Method and system for implementing hot swapping of virtual serial port based on proc technology
CN112764897B (en) Task request processing method, device and system and computer readable storage medium
US11604670B2 (en) Virtual machine live migration method, apparatus, and system
CN112181278B (en) Method, device, equipment and storage medium for creating system disk in cloud computing system
CN107454021B (en) Communication method and device
KR102567132B1 (en) Network data chaining apparatus, and control method thereof
CN116662037B (en) Processing method and device for shared memory, electronic equipment and storage medium
CN117076409B (en) File sharing method, device, system, electronic equipment and storage medium
CN117714398B (en) Data transmission system, method, electronic equipment and storage medium
EP4202675A1 (en) Information processing device, information processing method, and information processing program
CN112217773B (en) Firewall rule processing method, device and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20231130

Address after: Room 601, 6th Floor, Building 13, No. 3 Jinghai Fifth Road, Beijing Economic and Technological Development Zone (Tongzhou), Tongzhou District, Beijing, 100176

Patentee after: Beijing Youbixuan Intelligent Robot Co.,Ltd.

Address before: 518000 16th and 22nd Floors, C1 Building, Nanshan Zhiyuan, 1001 Xueyuan Avenue, Nanshan District, Shenzhen City, Guangdong Province

Patentee before: Shenzhen Youbixuan Technology Co.,Ltd.

TR01 Transfer of patent right
CB03 Change of inventor or designer information

Inventor after: Wang Ziyi

Inventor after: Dong Hao

Inventor after: Yang Guoping

Inventor before: Wang Ziyi

Inventor before: Zhao Mingguo

Inventor before: Dong Hao

Inventor before: Yang Guoping

CB03 Change of inventor or designer information