Data transmission method and device

By setting a preset send queue in the host, the parallel encapsulation and transmission of multiple pending data is realized, and the data is sent to multiple USB devices evenly, solving the problem of low data transmission efficiency under the USB protocol and improving overall processing speed.

CN119201819APending Publication Date: 2024-12-27ZHENGZHOU XINDA JIEAN INFORMATION TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411250965.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-06
Publication Date
2024-12-27

AI Technical Summary

Technical Problem

In application scenarios such as gateways, domain controllers, and background servers, due to the large amount of pending data that needs to be assisted in processing, hosts and external devices that use USB protocol communication have multiple problems in data transmission, including that the host can only be used at a time Sending a pending data will result in a long transmission time, affecting the overall processing speed, and lacking an equalization mechanism for data transmission, resulting in a reduced data processing speed.

Method used

By setting a preset send queue, it supports parallel encapsulation and filling of multiple pending data, saves data encapsulation time, realizes parallel transmission of multiple pending data, and sends data to multiple USB devices evenly, making full use of each USB The data processing capability of the device.

Benefits of technology

It saves the transmission time of multiple pending data, improves the overall processing speed, makes full use of the data processing capabilities of USB devices, and improves the data processing speed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119201819A_ABST
    Figure CN119201819A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a data transmission method and device. The method comprises the following steps: acquiring a plurality of node application requests; distributing sending nodes in a preset sending queue to each node application request; packaging the to-be-processed data of each user and the corresponding sending node identifier in parallel according to a preset communication protocol, and filling the packaged to-be-processed data into the corresponding sending node; sending the to-be-processed data filled in the sending node to each USB device in a balanced manner; and obtaining operation result data fed back by each USB device. According to the technical scheme provided by the embodiment of the invention, the to-be-processed data of each user and the corresponding sending node identifier can be packaged in parallel according to the preset communication protocol, so that the transmission time of a plurality of pieces of to-be-processed data is saved. And meanwhile, the to-be-processed data filled in the sending node is sent to each USB device in a balanced manner, so that the data processing capability of each USB device is fully utilized, and the data processing speed is increased.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the field of communication technology, and in particular to a data transmission method and device. Background Art

[0002] With the development of technology and economy, computers are becoming more and more popular in people's social life, and their application fields are becoming more and more extensive. Generally speaking, a computer consists of a host and external devices. Among them, the host includes core components such as the central processing unit, memory, and hard disk, which complete most of the computer's calculations. External devices communicate with the host through various communication protocols to assist the host in completing computing tasks such as input, output, network connection, and encryption. Among them, the USB (Universal Serial Bus) communication protocol has gradually become the most widely used communication protocol between the host and external devices due to its advantages such as high communication efficiency and support for hot plugging.

[0003] However, in application scenarios such as the host being a gateway, domain controller, or background server, since there is a large amount of data to be processed that needs to be assisted in processing, the host needs to send the data to be processed by multiple users to multiple external devices for auxiliary processing, which is not friendly to the host and external devices that communicate using the USB protocol.

[0004] Specifically, on the one hand, in the prior art, the host can only encapsulate one data to be processed at a time and send it to the external device, resulting in a long transmission time for multiple data to be processed and affecting the overall data processing speed; on the other hand, the data transmission between the host and multiple external devices lacks a balancing mechanism, which will also lead to a decrease in the overall data processing speed. Summary of the invention

[0005] The embodiments of the present invention aim to solve one of the technical problems in the related art at least to a certain extent.

[0006] To this end, an embodiment of the present invention discloses a data transmission method and device, which supports parallel encapsulation and filling of multiple data to be processed by setting a preset sending queue, saving the encapsulation time of the data to be processed, thereby saving the transmission time of multiple data to be processed and improving the overall processing speed.

[0007] In a first aspect, an embodiment of the present invention provides a data transmission method, which is applied to a host, wherein the host is communicatively connected with a plurality of USB devices, and the method comprises: Obtain multiple node application requests, wherein each node application request is initiated by a user; Allocate the sending nodes in the preset sending queue to each node application request; In parallel, the to-be-processed data of each user and the corresponding sending node identifier are encapsulated according to a preset communication protocol, and the encapsulated to-be-processed data is filled into the corresponding sending node; Sending the to-be-processed data filled into the sending node to each of the USB devices in a balanced manner; Obtaining the operation result data fed back by each of the USB devices; wherein the operation result data includes a receiving node identifier, and the sending node identifier and the receiving node identifier correspond one to one.

[0008] In a specific embodiment of the first aspect, encapsulating the to-be-processed data of each user and the corresponding sending node identifier in parallel according to a preset communication protocol, and filling the encapsulated to-be-processed data into the corresponding sending node, includes: The data to be processed of each user is divided in parallel, each divided data and the corresponding sending node identifier are encapsulated into a data packet of a preset size according to a preset communication protocol, and the data packet is filled into the corresponding sending node; The method includes: sending the to-be-processed data filled in the sending node to each of the USB devices in a balanced manner, including: The data packets filled in the sending node are sent to each USB device in a balanced manner; wherein the number of data packets sent to each USB device each time is at most n, and n is determined according to the maximum cache data volume of the data received by the USB device and the preset size.

[0009] In a specific embodiment of the first aspect, the data packets filled in the sending node are sent to each of the USB devices in a balanced manner, including: When the number of sending nodes in the filling state is greater than or equal to n*m, n data packets are allocated and sent to each USB device; wherein m is the number of the USB devices; When the number of sending nodes in the filling state is less than n*m, x data packets are allocated and sent for p of the USB devices, and x+1 data packets are allocated and sent for q of the USB devices; wherein, p+q=m, xp+(x+1)q=y, x=[y / m], and y is equal to the number of sending nodes currently in the filling state.

[0010] In a specific embodiment of the first aspect, the data packets filled in the sending node are sent to each of the USB devices in a balanced manner, including: When the number of sending nodes in the filling state is greater than or equal to n*m, n data packets are allocated and sent to each USB device; wherein m is the number of the USB devices; When the number of sending nodes in the filling state is less than n*m, and the number of sending nodes in the filling state plus the number of remaining applied sending nodes is greater than or equal to n*m, wait until the number of sending nodes in the filling state is greater than or equal to n*m, and allocate and send n data packets to each of the USB devices; When the number of sending nodes in the filling state is less than n*m, and the number of sending nodes in the filling state plus the remaining number of applied sending nodes is less than n*m, when all sending nodes are filled, x data packets are allocated and sent for p of the USB devices, and x+1 data packets are allocated and sent for q of the USB devices; wherein, p+q=m, xp+(x+1)q=y, x=[y / m], and y is equal to the number of sending nodes in the filling state when all sending nodes are filled.

[0011] In a specific embodiment of the first aspect, the data packets filled in the sending node are sent to each of the USB devices in a balanced manner, including: When the number of sending nodes in the filling state is greater than or equal to n*m, n data packets are allocated and sent to each USB device; wherein m is the number of the USB devices; When the number of sending nodes in the filling state is greater than or equal to s*m and less than n*m, x' data packets are allocated and sent for p' USB devices, and x'+1 data packets are allocated and sent for q' USB devices; wherein p'+q'=m, x'p'+(x'+1)q'=y', x'=[y / m], y' is equal to the number of sending nodes currently in the filling state; wherein s≥2; When the number of sending nodes in the filling state is less than s*m, s data packets are allocated and sent for p'' USB devices, and r data packets are allocated and sent for 1 USB device; wherein, sp''+r=y', r≤s.

[0012] In a specific embodiment of the first aspect, the data packets filled in the sending node are sent to each of the USB devices in a balanced manner, including: When the number of sending nodes in the filling state is greater than or equal to n*m, n data packets are allocated and sent to each USB device; wherein m is the number of the USB devices; When the number of sending nodes in the filling state is less than n*m, and the number of sending nodes in the filling state plus the number of remaining applied sending nodes is greater than or equal to n*m, wait until the number of sending nodes in the filling state is greater than or equal to n*m, and allocate and send n data packets to each of the USB devices; When the number of sending nodes in the filling state is less than n*m, and the number of sending nodes in the filling state plus the number of remaining sending nodes that have been applied for is greater than or equal to s*m and less than n*m, when all sending nodes are filled, x' data packets are allocated and sent for p' USB devices, and x'+1 data packets are allocated and sent for q' USB devices; wherein p'+q'=m, x'p'+(x'+1)q'=y', x'=[y / m], y' is equal to the number of sending nodes in the filling state when all sending nodes are filled; wherein s≥2; When the number of sending nodes in the filling state plus the number of remaining applied sending nodes is less than s*m, when all sending nodes are filled, s data packets are allocated and sent for p'' USB devices, and r data packets are allocated and sent for 1 USB device; wherein, sp''+r=y', r≤s.

[0013] In a specific embodiment of the first aspect, there are multiple preset sending queues, and the data to be processed with the same processing requirements are allocated to the sending nodes in the same preset sending queue, and the data to be processed with different processing requirements are allocated to the sending nodes in different preset sending queues.

[0014] In a specific embodiment of the first aspect, for each preset sending queue, the step of evenly sending the data to be processed filled in the sending node to each of the USB devices is performed in a preset order, and each preset sending queue sends the data to be processed of a preset length each time.

[0015] In a specific embodiment of the first aspect, the host is a multi-core processor, and the number of cores of the multi-core processor is equal to the number of preset sending queues; for each preset sending queue, each core independently executes the step of evenly sending the to-be-processed data filled in the sending node to each of the USB devices, and each preset sending queue sends the to-be-processed data of a preset length each time.

[0016] In a specific embodiment of the first aspect, the method further includes: Allocate a receiving node in a preset receiving queue to each node application request; wherein the sending node in the preset sending queue and the receiving node in the preset receiving queue are in a one-to-one correspondence, the preset receiving queue reuses the preset sending queue, or the preset receiving queue does not reuse the preset sending queue; Parsing the calculation result data and filling the calculation result data into the corresponding receiving node; Each user obtains the operation result data from the receiving node in parallel.

[0017] In a specific embodiment of the first aspect, obtaining the operation result data fed back by each of the USB devices includes: Poll each of the USB devices to obtain the calculation result data in each of the USB devices.

[0018] In a specific embodiment of the first aspect, the to-be-processed data filled in the sending node is sent to each of the USB devices in a balanced manner, including: The driver program obtains the data to be processed in the sending node, and uses a preset data structure to evenly send the obtained data to be processed to each of the USB devices; Obtaining the operation result data fed back by each of the USB devices, including: The driver program obtains the operation result data fed back by each of the USB devices.

[0019] In a specific embodiment of the first aspect, encapsulating the to-be-processed data of each user and the corresponding sending node identifier in parallel according to a preset communication protocol, and filling the encapsulated to-be-processed data into the corresponding sending node, includes: The to-be-processed data of each user and the corresponding sending node identifier are encapsulated in parallel according to a preset communication protocol, and the encapsulated to-be-processed data is filled into the corresponding sending node through a unique device file node; wherein the device file node is generated by the driver.

[0020] In a specific embodiment of the first aspect, the method further includes: For any data to be processed, if the calculation result data fed back by the external device is not received within the preset time period, the step of obtaining the node application request corresponding to the data to be processed is performed again.

[0021] In a specific embodiment of the first aspect, each sending node fills a data packet, and the preset size matches the single packet data length supported by the USB device.

[0022] In a specific embodiment of the first aspect, when the user is an application program and there are multiple data to be processed, the process of the user initiating a node application request includes: The user initiates node application requests for each piece of data to be processed; or, The user creates multiple threads, each of which initiates a node application request; or, Alternatively, the user merges multiple data to be processed into one data to be processed and initiates a node application request.

[0023] In a specific embodiment of the first aspect, the applied sending nodes are continuous, and the data packets sent to each of the USB devices originate from the continuous sending nodes.

[0024] In a specific embodiment of the first aspect, each of the USB devices is mounted on a PCIE bus and is communicatively connected to the host via a same PCIE interface.

[0025] In a second aspect, an embodiment of the present invention further discloses a data transmission device, which is applied to a host, and the host is communicatively connected with a plurality of USB devices, and the device comprises: An acquisition unit, used to acquire multiple node application requests, wherein each node application request is initiated by a user; An allocating unit, used for allocating a sending node in a preset sending queue to each node application request; A filling unit, used to encapsulate the to-be-processed data of each user and the corresponding sending node identifier in parallel according to a preset communication protocol, and fill the encapsulated to-be-processed data into the corresponding sending node; A sending unit, used for sending the to-be-processed data filled in the sending node to each of the USB devices in a balanced manner; The receiving unit is used to obtain the operation result data fed back by each of the USB devices; wherein the operation result data includes a receiving node identifier, and the sending node identifier and the receiving node identifier correspond one to one.

[0026] Beneficial effects of the embodiments of the present invention: A data transmission method and device provided by an embodiment of the present invention is applied to a host, and the host is connected to multiple USB devices in communication. The method includes: obtaining multiple node application requests; assigning a sending node in a preset sending queue to each node application request; encapsulating the to-be-processed data of each user and the corresponding sending node identifier in parallel according to a preset communication protocol, and filling the encapsulated to-be-processed data into the corresponding sending node; sending the to-be-processed data filled into the sending node to each USB device in a balanced manner; and obtaining the operation result data fed back by each USB device. The technical solution of the embodiment of the present invention allocates a sending node in a preset sending queue to each node application request, so that each node application request has a sending node respectively, and then the to-be-processed data of each user and the corresponding sending node identifier can be encapsulated in parallel according to the preset communication protocol, so as to realize the parallel encapsulation of the to-be-processed data of each user. Compared with the traditional serial communication, since there is no need to wait for the encapsulation of the previous to-be-processed data to be completed before encapsulating the next to-be-processed data, the encapsulation time of the to-be-processed data is saved, and then the transmission time of multiple to-be-processed data is saved, and the overall processing speed is also improved. At the same time, the to-be-processed data filled into the sending node is sent to each USB device in a balanced manner, making full use of the data processing capacity of each USB device, and improving the data processing speed. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] Figure 1 A schematic diagram of a data transmission method according to an embodiment of the present invention; Figure 2 A schematic diagram of a flow chart of another data transmission method provided by an embodiment of the present invention; Figure 3 A schematic diagram of the structure of a data transmission device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0028] In order to more clearly understand the above-mentioned purposes, features and advantages of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the technical concept of the embodiments of the present invention belong to the scope of protection of the present invention.

[0029] Referring to the background technology, there is an application scenario in which the host needs to send the to-be-processed data of multiple users to an external device through a USB interface for auxiliary processing. In the prior art, the host can only encapsulate one to-be-processed data at a time and send it to an external device, resulting in a long transmission time for multiple to-be-processed data and affecting the overall data processing speed; in addition, the data transmission between the host and multiple external devices lacks a balancing mechanism, which will also lead to a reduction in the overall data processing speed. In response to this problem, an embodiment of the present invention provides a data transmission method and device, which supports the parallel encapsulation and filling of multiple to-be-processed data by setting a preset sending queue, saving the encapsulation time of the to-be-processed data, thereby saving the transmission time of multiple to-be-processed data, and also improving the overall processing speed. At the same time, the to-be-processed data filled in the sending node is sent to each USB device in a balanced manner, making full use of the data processing capabilities of each USB device and improving the data processing speed. The following is a more detailed description of the embodiment of the present invention.

[0030] Before describing the data transmission method of the embodiment of the present invention, the application scenario of the embodiment of the present invention is first exemplified so as to have a more intuitive understanding of the technical solution of the embodiment of the present invention. One possible scenario is that a background server connected to multiple USB devices (such as a background server providing high-precision map services, a server providing government services, etc.) provides services for terminal devices accessing it. Each terminal device needs to determine the identity of the background server, and the background server needs to sign the information to be sent to the terminal device (i.e., the data to be processed). At this time, the background server needs to send multiple data to be processed to multiple USB devices for signing. Another possible scenario is that the host needs multiple USB devices connected to it to assist in encrypting multiple data to be processed. At this time, the host needs to send multiple data to be processed to multiple USB devices for encryption. It should be noted that this is only an exemplary description of the application scenario of the embodiment of the present invention. The data transmission method of the embodiment of the present invention is not limited to the aforementioned application scenario. The working conditions such as gateways and domain controllers that need to process multiple data to be processed through external USB devices can all use the technical solution provided by the embodiment of the present invention.

[0031] Furthermore, after the application scenarios of the embodiments of the present invention are exemplarily described, the technical solution itself is described in conjunction with the accompanying drawings. Figure 1 As shown, Figure 1A flow chart of a data transmission method provided by an embodiment of the present invention. The data transmission method is applied to a host, and the host is connected to multiple USB devices. The host can be a background server, a desktop host, a laptop, a gateway, a domain controller, etc., which can be connected to multiple USB devices, and multiple USB devices are required to sign, hash and / or encrypt multiple data to be processed. The USB device can be an electronic device such as an encryption card, a multimedia computer, etc., which can assist the host in data processing.

[0032] Specifically, Figure 1 The data transmission method shown comprises the following steps: In step S101, multiple node application requests are obtained.

[0033] Each node application request is initiated by a user. In actual applications, a user can be an application or a thread of an application. When a user needs to send data to be processed to an external device for data processing, the user initiates a node application request.

[0034] In step S102, a sending node in a preset sending queue is allocated to each node application request.

[0035] Among them, the preset sending queue can be pre-configured in the kernel of the host, and each sending node in the preset sending queue has a corresponding sending node identifier. It can be understood that the sending node here is a logical node. For any node application request, the number of nodes allocated for the node application request is determined according to the length of the pending data of the user who initiated the node application request and the storage space of each sending node. For example, the effective data length that can be stored in the storage space of each sending node in the preset sending queue is 2KB, and the length of the pending data of the user who initiated a node application request is 10KB, then 5 sending nodes need to be allocated for the node application request. It can be concluded here that the node application request should include the length information of the user's pending data. It should be noted that when the effective data length that can be stored in the storage space of each sending node is 2KB, 2KB is only the effective data length, and the storage space of each sending node should actually be greater than 2KB, because the storage space of each sending node needs to store data description information such as data length and check value in addition to storing the effective data length.

[0036] Generally, a sending node is assigned to each node application request according to the order in which each user initiates the node application request, and the sending nodes corresponding to each node application request are continuous, and the sending nodes of each node application request are also continuous. Of course, in theory, there can be other allocation rules, such as assigning each sending node to each node application request at intervals. But it is obvious that the sequential allocation method is simple in logic, easier to implement in code, and in line with people's thinking habits.

[0037] In step S103, the to-be-processed data of each user and the corresponding sending node identifier are encapsulated in parallel according to a preset communication protocol, and the encapsulated to-be-processed data is filled into the corresponding sending node.

[0038] Among them, the preset encapsulation protocol is a private communication data packet format between the host and the USB device. The host encapsulates the data to be processed according to this data packet format and fills it into the corresponding sending node. The destination mark data source identified by the encapsulated sending node is convenient for establishing the corresponding relationship between the host's data to be processed and the calculation result data of the external device. Generally, the preset encapsulation protocol is related to the data processing requirements. For example, if the data to be processed needs to be signed by SM2, the preset encapsulation protocol is the data packet format required by the SM2 key interaction protocol.

[0039] Furthermore, when the user's pending data is long and there are multiple sending nodes assigned to the user's pending data, it is necessary to divide the pending data of each user in parallel, encapsulate each divided data and the corresponding sending node identifier into a data packet of a preset size according to the preset communication protocol, and fill the data packet into the corresponding sending node. Generally, the preset size matches the storage space size of the sending node, that is, one data packet occupies one sending node. Obviously, the length of each divided data is also related to the preset size, and it is necessary to satisfy that the length after encapsulating the divided data and the corresponding sending node identifier is equal to the preset size. If the remaining data length after the division is not enough to fill a sending node, the remaining data length and the corresponding sending node identifier are also encapsulated into a data packet. In addition, in actual applications, when setting the storage space and preset size of each sending node, the single-packet data length supported by the external device can be considered at the same time, so that the preset size matches the single-packet data length supported by the external device, that is, the length of the divided data is equal to the single-packet data length supported by the external device. In this way, the external device can directly process the received data packet, further improving the data processing and transmission efficiency.

[0040] It should be noted that, in theory, the storage space of each sending node can be designed to be large enough, and there is no need to split the data to be processed, but this will cause a waste of storage space, and because the lengths of the data to be processed are different or even quite different, it may cause a large gap in filling time, which ultimately affects the data transmission efficiency. In addition, in theory, multiple data packets can also be stored in one sending node, but this will require the storage order of multiple data packets belonging to the same sending node to be stored at the same time, and multiple data packets belonging to the same sending node cannot be stored synchronously, which will make the data transmission logic complicated and affect the data transmission efficiency to a certain extent. Therefore, it is generally adopted to split the data to be processed, and to separately assign a sending node to each data packet obtained by encapsulating the split data and the sending node identifier. It is understandable that when the length of the data to be processed is small and one sending node can meet the filling requirements, there is no need to split the data to be processed.

[0041] In this step, the parallel relationship between the sending nodes enables each user's to-be-processed data and the corresponding sending node identifier to be encapsulated according to the preset communication protocol, and the process of filling the encapsulated to-be-processed data into the corresponding sending node can be carried out in parallel without affecting each other, thereby realizing the parallel encapsulation and filling of multiple to-be-processed data. Compared with the prior art, multiple to-be-processed data do not need to be encapsulated sequentially. In addition, due to the high transmission rate of USB, the parallel processing method can greatly improve the overall data transmission efficiency.

[0042] In step S104, the data to be processed filled in the sending node is sent to each USB device in a balanced manner.

[0043] Specifically, the to-be-processed data filled into the sending node is evenly distributed to each USB device using a pre-configured distribution algorithm. The distribution algorithm is an algorithm that distributes the to-be-processed data in the sending node to each USB device. Generally, the distribution algorithm should be able to balance the to-be-processed data distributed to each USB device. For example, it can be a polling algorithm. Of course, it can also be other existing algorithms or algorithms designed by the inventor that can evenly distribute the to-be-processed data in the sending node.

[0044] In step S105, the calculation result data fed back by each USB device is obtained.

[0045] The operation result data includes a receiving node identifier, and the sending node identifier and the receiving node identifier correspond one to one. Generally, the sending node identifier and the receiving node identifier are the same, so as to characterize the correspondence between the operation result data and the sending node, or the one-to-one correspondence between the operation result data and the encapsulated data to be processed.

[0046] In practical applications, the calculation result data in each USB device can be obtained by polling.

[0047] It should be noted that, due to the characteristics of the USB protocol, the host needs to actively send a request to obtain the operation result to the USB device to obtain the operation result data fed back by the USB device.

[0048] The data transmission method provided by the embodiment of the present invention is applied to a host, and the host is connected to multiple USB devices in communication. The method includes: obtaining multiple node application requests; assigning a sending node in a preset sending queue to each node application request; encapsulating the to-be-processed data of each user and the corresponding sending node identifier in parallel according to a preset communication protocol, and filling the encapsulated to-be-processed data into the corresponding sending node; sending the to-be-processed data filled into the sending node to each USB device in a balanced manner; and obtaining the operation result data fed back by each USB device. The technical solution of the embodiment of the present invention allocates a sending node in a preset sending queue to each node application request, so that each node application request has a sending node respectively, and then the to-be-processed data of each user and the corresponding sending node identifier can be encapsulated in parallel according to the preset communication protocol, realizing the parallel encapsulation of the to-be-processed data of each user, saving the transmission time of multiple to-be-processed data, and also improving the overall processing speed. At the same time, the to-be-processed data filled into the sending node is evenly sent to each USB device, making full use of the data processing capacity of each USB device, and improving the data processing speed.

[0049] Furthermore, for the implementation method of dividing the data to be processed of each user in parallel, encapsulating each divided data and the corresponding sending node identifier into a data packet of a preset size according to a preset communication protocol, and filling the data packet into the corresponding sending node, considering that the actual transmission capacity of the USB transmission protocol is strong and the encapsulated data packet is generally small, if the host sends a data packet in a sending node at a time, the transmission efficiency and processing rate of the data to be processed will be affected, resulting in low transmission efficiency and processing efficiency of the data to be processed. To this end, in some implementations of the embodiments of the present invention, the encapsulated data packets are transmitted in a batch transmission manner. Specifically, step S104 may include: The data packets filled in the sending node are sent to each USB device in a balanced manner.

[0050] The maximum number of data packets sent to each USB device each time is n, where n is determined according to the maximum cache data volume and preset size of the data received by the USB device. For example, if the maximum cache data volume of the data received by the USB device is 26KB and the preset size is 2KB, then n is equal to 13. In practical applications, n data packets can be packaged and sent to the USB device.

[0051] It should be noted that when there are sufficient data packets in the sending node, the number of data packets sent to each USB device each time is n, and when there are fewer data packets in the sending node, the number of data packets sent to each USB device each time may be less than n.

[0052] This specific implementation method transmits data packets in batches, fully utilizing the strong actual transmission capability of the USB transmission protocol, thereby improving the transmission efficiency and overall processing efficiency of the data to be processed.

[0053] Furthermore, considering that in some working conditions, the number of data packets filled into the sending node is dynamically changing, or is not sufficient, or is not equal to an integer multiple of the number of USB devices, some possible implementations of step S104 are described as follows: In some implementations A1 of the embodiments of the present invention, step S104 may include: When the number of sending nodes in the filling state is greater than or equal to n*m, n data packets are allocated and sent to each USB device; where m is the number of USB devices; When the number of sending nodes in the filling state is less than n*m, x data packets are allocated and sent for p USB devices, and x+1 data packets are allocated and sent for q USB devices; where p+q=m, xp+(x+1)q=y, x=[y / m], y is equal to the number of sending nodes currently in the filling state, and [] represents rounding operation.

[0054] The remaining number of applied sending nodes refers to the number of sending nodes that have been applied for but not yet filled each time step S104 is executed. Obviously, in some working conditions, the number of sending nodes that have been applied for but not yet filled can be equal to 0.

[0055] It should be noted that, since the data in the sending node is constantly filled, the number of sending nodes in the filling state is constantly changing. Therefore, each time step S104 is executed, the number of sending nodes in the filling state is obtained in real time. In addition, when the number of sending nodes in the filling state is less than n*m but equal to an integer multiple of m, q=0. Obviously, when the number of sending nodes in the filling state is less than m, p=0.

[0056] Through implementation method A1, when the number of sending nodes in the filling state is less than n*m, the number of data packets allocated to each USB device differs by at most 1, and the data processing volume of each USB device is more balanced, thereby improving data processing efficiency.

[0057] Further, in parallel with the aforementioned implementation A1, in some implementations A2 of the embodiments of the present invention, step S104 may include: When the number of sending nodes in the filling state is greater than or equal to n*m, n data packets are allocated and sent to each USB device; where m is the number of USB devices; When the number of sending nodes in the filling state is less than n*m, and the number of sending nodes in the filling state plus the number of remaining sending nodes that have been applied for is greater than or equal to n*m, wait until the number of sending nodes in the filling state is greater than or equal to n*m, and allocate and send n data packets to each USB device; When the number of sending nodes in the filling state is less than n*m, and the number of sending nodes in the filling state plus the remaining number of applied sending nodes is less than n*m, when all sending nodes are filled, x data packets are allocated and sent for p USB devices, and x+1 data packets are allocated and sent for q USB devices; among which, p+q=m, xp+(x+1)q=y, x=[y / m], and y is equal to the number of sending nodes in the filling state when all sending nodes are filled.

[0058] Compared with Implementation A1, Implementation A2 can reduce the number of data transmissions as much as possible through reasonable waiting according to the filling and application status of the sending node, so as to improve the overall processing speed.

[0059] Further, considering that the number of data packets filled into the sending node is small, it may happen that allocating data packets to more USB devices may result in lower overall data processing efficiency than allocating them to fewer USB devices, but higher power consumption. The reason for this is that when the USB device has sufficient processing capacity, the time consumed to transmit and process one data packet is substantially equal to the time consumed to transmit and process two or more data packets. The scheduling process required to allocate these data packets to more USB devices may take longer. To this end, in some implementations B1 of the embodiments of the present invention, step S104 may include: When the number of sending nodes in the filling state is greater than or equal to n*m, n data packets are allocated and sent to each USB device; where m is the number of USB devices; When the number of sending nodes in the filling state is greater than or equal to s*m and less than n*m, x' data packets are allocated and sent for p' USB devices, and x'+1 data packets are allocated and sent for q' USB devices; where p'+q'=m, x'p'+(x'+1)q'=y', x'=[y / m], y' is equal to the number of sending nodes currently in the filling state; When the number of sending nodes in the filling state is less than s*m, s data packets are allocated and sent for p'' USB devices, and r data packets are allocated and sent for 1 USB device; wherein, sp''+r=y', r≤s.

[0060] The value of s is related to the processing capability of the USB device, and the value of s should satisfy the following conditions: the overall data processing speed of allocating s data packets to two USB devices is higher than that of allocating s data packets to one USB device, and the overall data processing speed of allocating s+1 data packets to two USB devices is lower than that of allocating s data packets to one USB device. Obviously, s≥2.

[0061] It should be noted that: when y' is greater than or equal to s*m and less than n*m and equal to an integer multiple of m, q'=0. When y'≤s, p''=0.

[0062] By implementing the method B1, when the number of sending nodes in the filling state is greater than or equal to s*m and less than n*m, the number of data packets allocated to each USB device differs by at most 1, and the data processing amount of each USB device is relatively balanced, thereby improving the data processing efficiency. At the same time, when the number of sending nodes in the filling state is less than s*m, fewer USB devices are allocated to process data packets, thereby improving the overall data processing efficiency.

[0063] Further, in parallel with the aforementioned implementation B1, in some implementations B2 of the embodiments of the present invention, step S104 may include: When the number of sending nodes in the filling state is greater than or equal to n*m, n data packets are allocated and sent to each USB device; where m is the number of USB devices; When the number of sending nodes in the filling state is less than n*m, and the number of sending nodes in the filling state plus the number of remaining sending nodes that have been applied for is greater than or equal to n*m, wait until the number of sending nodes in the filling state is greater than or equal to n*m, and allocate and send n data packets to each USB device; When the number of sending nodes in the filling state is less than n*m, and the number of sending nodes in the filling state plus the number of remaining applied sending nodes is greater than or equal to s*m and less than n*m, when all sending nodes are filled, x' data packets are allocated and sent for p' USB devices, and x'+1 data packets are allocated and sent for q' USB devices; wherein p'+q'=m, x'p'+(x'+1)q'=y', x'=[y / m], y' is equal to the number of sending nodes in the filling state when all sending nodes are filled; When the number of sending nodes in the filling state plus the number of remaining sending nodes that have applied for sending is less than s*m, when all sending nodes are filled, s data packets are allocated and sent for p'' USB devices, and r data packets are allocated and sent for 1 USB device; among them, sp''+r=y', r≤s.

[0064] Compared with Implementation Method B1, Implementation Method B2 can reduce the number of data transmissions as much as possible through reasonable waiting according to the filling and application status of the sending node, so as to improve the overall processing speed.

[0065] Furthermore, considering the situation that the USB device supports multiple operations, such as some password cards simultaneously supporting SM2 signature operation, SM3 hash operation and SM4 encryption and decryption operation. The inventors have come up with the idea of ​​configuring preset sending queues for the to-be-processed data with different processing requirements, and for each preset sending queue, synchronously and parallelly executing the steps of encapsulating the to-be-processed data of each user and the corresponding sending node identifier according to the preset communication protocol, so as to realize the synchronous transmission and processing of the to-be-processed data with different requirements, and further improve the data transmission efficiency.

[0066] Specifically, in some implementations of the embodiments of the present invention, there are multiple preset sending queues, and the to-be-processed data with the same processing requirements are allocated to the sending nodes in the same preset sending queue, and the to-be-processed data with different processing requirements are allocated to the sending nodes in different preset sending queues. It should be noted that when there are multiple preset sending queues, if a batch transmission method is adopted, the steps of evenly sending the data packets filled in the sending nodes to each USB device are respectively performed for each preset sending queue, that is, the number of data packets corresponding to each preset sending queue is counted separately. In addition, in order to enable the USB device to distinguish data from different preset sending queues, the data packets sent to each USB device should also include a queue identifier. Of course, the corresponding operation result data should also include the same queue identifier.

[0067] Furthermore, when there are multiple preset sending queues, different preset sending queues may preempt or continuously occupy the USB device, resulting in the inability to carry out related services in a timely manner. In some implementations of the embodiments of the present invention, for each preset sending queue, the step of evenly sending the data to be processed filled in the sending node to each USB device is performed in a preset order, and each preset sending queue sends the data to be processed of a preset length each time. Among them, the preset order of each preset sending queue can be agreed in advance in the host. The preset length can be flexibly set according to actual needs. For example, the preset length can be equal to the length of a preset number of data packets, and the preset number is determined according to the maximum cache data volume and the preset size of the data received by the USB device. In addition, in actual applications, different logical channels can be configured for the data to be processed with different processing requirements so that the USB device can distinguish the received data.

[0068] In this specific implementation, each preset sending queue sends a preset length of pending data each time, and each preset sending queue cyclically sends the pending data in a preset order to balance the transmission and processing of pending data for various processing requirements, avoid continuous inability to execute related services, and improve user experience.

[0069] In particular, when the host has a multi-core processor, each core can independently send data to be processed to the USB device.

[0070] Specifically, in some implementations of the embodiments of the present invention, the host is a multi-core processor, and the number of cores of the multi-core processor is equal to the number of preset sending queues, that is, each core is responsible for a preset sending queue; for each preset sending queue, each core independently executes the step of evenly sending the data to be processed filled in the sending node to each USB device, and each preset sending queue sends the data to be processed of a preset length each time. It should be noted that when one core sends data to be processed to a certain USB device, because the channel is occupied, another core cannot send data to be processed to the same USB device, but the other core can send data to be processed to other USB devices.

[0071] It should also be noted that when there are multiple preset sending queues, when a certain USB device is polled, the calculation result data of various processing requirements in the USB device are obtained. The calculation result data of different processing requirements can be distinguished by the queue identifier.

[0072] In addition, in actual applications, USB devices that do not process data will not be polled. Specifically, when polling each USB device, the occupancy flag corresponding to the USB device will be determined first. The occupancy flag is set to 1 during the sending phase and cleared to 0 after the reception is completed. The occupancy flag is 1, indicating that the USB device can perform data reception operations, and the occupancy flag is cleared to 0 after successful reception.

[0073] Alternatively, see Figure 2 As shown, in Figure 1 Based on the illustrated embodiment, the data transmission method of the embodiment of the present invention may further include: In step S201, a receiving node in a preset receiving queue is allocated to each node application request.

[0074] Among them, the preset receiving queue can be pre-configured in the kernel of the host, and is specifically obtained by the driver program. The sending node in the preset sending queue and the receiving node in the preset receiving queue are in a one-to-one correspondence. Correspondingly, the sending node identifier and the receiving node identifier also correspond one-to-one. In addition, it is obvious that it is necessary to ensure that each sending node and receiving node only corresponds to one user, and there will not be a situation where multiple users apply for the same sending node or receiving node.

[0075] In step S202, the calculation result data is parsed and filled into the corresponding receiving node.

[0076] Specifically, the corresponding receiving node is determined according to the receiving node identifier in the operation result data.

[0077] In step S203, each user obtains the calculation result data from the receiving node in parallel.

[0078] It can be understood that when there are multiple preset sending queues, there are also multiple preset receiving queues, and the preset sending queues and the preset receiving queues correspond one-to-one. The one-to-one corresponding preset sending queues and preset receiving queues have the same queue identifier, and the preset receiving queue corresponding to the calculation result data can be determined according to the queue identifier.

[0079] In this specific implementation, by setting a preset receiving queue, each user can obtain operation result data from the receiving node in parallel, further improving data transmission efficiency.

[0080] In particular, since sending and receiving are sequential, in theory, after the data in the sending node of the preset sending queue is sent out, the subsequently received calculation result data can be filled into the node, that is, the preset receiving queue reuses the preset sending queue. Of course, the preset receiving queue may not reuse the preset sending queue. Generally, the method of using the preset receiving queue not to reuse the preset sending queue is adopted, so that it is easy to implement when programming, and easy to troubleshoot when errors occur.

[0081] Optionally, in some implementations of the embodiments of the present invention, step S104 and step S105 are executed by a driver program located in the kernel, specifically by a kernel thread in the driver program, and the other steps are executed by an application program in the user space. It should be noted that the application program in the user space here is not the user who initiates the node application request, and the application program can be understood as an application program that executes the data transmission method of the embodiment of the present invention. The kernel thread plays a monitoring role and a sending and receiving role. When the data of the sending node meets the sending requirements, the corresponding data to be processed is sent to the USB device, and the operation result data fed back by the USB device is obtained.

[0082] Specifically, step S104 includes: The driver obtains the data to be processed in the sending node, and uses a preset data structure to evenly send the obtained data to be processed to each USB device.

[0083] Specifically, the preset data structure is used for the driver to manage each USB device. In actual use, the preset data structure can be an array or a linked list; the elements in the preset data structure are the device description information of each USB device, and the device description information is used to characterize the USB device, generally including: device ID, device type, device status, etc. The driver can evenly distribute and send the data to be processed to each USB device according to the device description information in the preset data structure or the number of USB devices and the status of each USB device.

[0084] The preset data structure is set during the driver loading phase. Specifically, during the initialization phase when the host detects each USB device, each time a USB device is detected, corresponding device description information is created, and then the device description information is added as an element to the preset data structure.

[0085] Step S105 includes: The driver obtains the operation result data fed back by each USB device.

[0086] For example, for Figure 1 In the embodiment shown, steps S101, S102 and S103 are executed by the application program in the user space, and steps S104 and S105 are executed by the driver program. Figure 2 In the illustrated embodiment, step S101, step S102, step S103 and step S201 are executed by an application program in the user space, and step S104, step S105 and step S202 are executed by a driver program.

[0087] In this implementation, the driver is responsible for sending the to-be-processed data in the preset sending queue to the USB device, and obtaining the operation result data returned by the USB device. When a preset receiving queue is also included, the driver is also used to parse the operation result data and put the operation result data into the node corresponding to the receiving queue for the user to read.

[0088] In actual development, you can refer to the producer-consumer model in the design pattern. For the data sending process, the user space application is responsible for filling the to-be-processed data into the sending node of the preset sending queue, and the user space application belongs to the producer; the driver is responsible for sending the data in the sending node of the preset sending queue to the USB device, and the driver is a consumer. For the data receiving process, the driver is responsible for receiving the operation result data returned by the USB device, parsing the operation result data, and filling the parsed operation result data into the corresponding receiving node of the preset receiving queue, and the driver belongs to the producer; the user space application is responsible for returning the operation result data in the receiving node of the preset receiving queue to the address specified by the user, and the user space application belongs to the consumer.

[0089] In particular, the above process can also be entirely implemented by the application in the user space. The purpose of using the driver is to ensure that while the application in the user space is continuously filling the data to be processed into the sending node of the preset sending queue, the driver can simultaneously send the already filled data to be processed to the USB device, and then request the USB device for the processed operation result data, and fill the requested operation result data into the receiving node corresponding to the preset receiving queue. It can be seen that the processing process of the application in the user space and the processing process of the driver can overlap in time, so the use of the driver to be responsible for sending and receiving improves the data transmission efficiency and processing efficiency as a whole. At the same time, since the driver is used to manage each USB device and is responsible for sending and receiving, the work of the application in the user space is simplified, and when USB devices are added, there is no need to modify the application.

[0090] Furthermore, when the driver implements the management of each USB device and the sending and receiving of receipts, step S103 may include: In parallel, the to-be-processed data of each user and the corresponding sending node identifier are encapsulated according to a preset communication protocol, and the encapsulated to-be-processed data is filled into the corresponding sending node through a unique device file node.

[0091] After completing the detection of all USB devices, the driver generates a device file node in the operating system / dev directory, and all USB devices share the device file node. In this case, the user space application does not know how many USB devices there are. No matter how many USB devices there are, the only device file node generated by the driver in the operating system / dev directory is the only channel for the application to communicate with the USB device.

[0092] Specifically, the process by which the user-space application fills the encapsulated data to be processed into the corresponding sending node through a unique device file node is as follows: the user-space application calls the open function through the device file node to obtain a file handle, uses the file handle to call the mmap function provided by the kernel to obtain the address of the preset sending queue, and then fills the encapsulated data to be processed into the corresponding sending node.

[0093] It should be noted that, in theory, a device file node can be created for each USB device, but the management is complicated, and when the number of USB devices changes, the application program in the user space needs to be modified.

[0094] Considering that in actual applications, due to various reasons such as the interruption of the connection between the host and the external device, the host fails to receive the calculation result data in time, which leads to the failure of related services. To this end, in some implementations of the embodiments of the present invention, the data transmission method may also include: for any data to be processed, if the calculation result data fed back by the external device is not received within a preset time, the step of obtaining the node application request corresponding to the data to be processed is executed again. The preset time is determined according to the needs of the related services.

[0095] In this implementation, for any data to be processed, when the calculation result data fed back by the external device is not received within the preset time period, the step of obtaining the node application request corresponding to the data to be processed is executed again to execute the processing and transmission process of the data to be processed again, thereby improving the business success rate.

[0096] It should be noted that, in theory, for any data to be processed, if the calculation result data fed back by the external device is not received within the preset time, the step of evenly sending the data to be processed filled in the sending node to each USB device can be executed again. However, this implementation method requires retaining the data to be processed in the sending node until the corresponding calculation result data is received, and requires the design of corresponding data search logic, which is more complicated than the method of directly obtaining the node application request corresponding to the data to be processed.

[0097] Furthermore, when the user is an application, each user may have multiple data to be processed. When the user is an application and there are multiple data to be processed, one possible solution is that the user initiates node application requests for each data to be processed respectively; another possible solution is that the user creates multiple threads, and each thread initiates a node application request; another possible solution is that the user merges multiple data to be processed into one data to be processed and initiates a node application request.

[0098] Furthermore, in order to simplify the program coding, generally, the applied sending nodes are continuous. And in order to ensure that the pending data of a certain user is continuously sent to each USB device, in some implementations of the embodiments of the present invention, the data packets sent to each USB device are from continuous sending nodes. Obviously, if the sending nodes at the lower order have been filled, but the sending nodes at the upper order have not been filled, it is necessary to wait until the sending nodes at the upper order are filled to ensure that the data packets sent to each USB device are from continuous sending nodes.

[0099] Optionally, in order to save the number of interfaces between the host and the external device, in some implementations of the embodiments of the present invention, each USB device is mounted on the PCIE bus and is connected to the host for communication via the same PCIE interface.

[0100] Corresponding to the above method embodiment, the embodiment of the present invention also discloses a data transmission device, which is applied to a host, and the host is connected to multiple USB devices for communication. Figure 3 As shown, the data transmission device of the embodiment of the present invention may include: an acquisition unit 301 , an allocation unit 302 , a filling unit 303 , a sending unit 304 and a receiving unit 305 .

[0101] The acquisition unit 301 is used to acquire multiple node application requests, wherein each node application request is initiated by a user; The allocation unit 302 is used to allocate the sending nodes in the preset sending queue to each node application request; The filling unit 303 is used to encapsulate the to-be-processed data of each user and the corresponding sending node identifier in parallel according to the preset communication protocol, and fill the encapsulated to-be-processed data into the corresponding sending node; The sending unit 304 is used to send the to-be-processed data filled in the sending node to each of the USB devices in a balanced manner; The receiving unit 305 is used to obtain the operation result data fed back by each of the USB devices; wherein the operation result data includes a receiving node identifier, and the sending node identifier and the receiving node identifier correspond one to one.

[0102] The data transmission device provided by the embodiment of the present invention is applied to a host, and the host is connected to multiple USB devices in communication. The method includes: obtaining multiple node application requests; assigning a sending node in a preset sending queue to each node application request; encapsulating the to-be-processed data of each user and the corresponding sending node identifier in parallel according to a preset communication protocol, and filling the encapsulated to-be-processed data into the corresponding sending node; sending the to-be-processed data filled into the sending node to each USB device in a balanced manner; and obtaining the operation result data fed back by each USB device. The technical solution of the embodiment of the present invention allocates a sending node in a preset sending queue to each node application request, so that each node application request has a sending node respectively, and then the to-be-processed data of each user and the corresponding sending node identifier can be encapsulated in parallel according to the preset communication protocol, realizing the parallel encapsulation of the to-be-processed data of each user, saving the transmission time of multiple to-be-processed data, and also improving the overall processing speed. At the same time, the to-be-processed data filled into the sending node is evenly sent to each USB device, making full use of the data processing capacity of each USB device and improving the data processing speed.

[0103] In some implementations of the embodiments of the present invention, the filling unit 303 is specifically used for: The data to be processed of each user is divided in parallel, each divided data and the corresponding sending node identifier are encapsulated into a data packet of a preset size according to a preset communication protocol, and the data packet is filled into the corresponding sending node; The sending unit 304 is specifically used for: The data packets filled in the sending node are sent to each USB device in a balanced manner; wherein the number of data packets sent to each USB device each time is at most n, and n is determined according to the maximum cache data volume of the data received by the USB device and the preset size.

[0104] In some implementations of the embodiments of the present invention, the sending unit 304 is specifically used to: When the number of sending nodes in the filling state is greater than or equal to n*m, n data packets are allocated and sent to each USB device; wherein m is the number of the USB devices; When the number of sending nodes in the filling state is less than n*m, x data packets are allocated and sent for p of the USB devices, and x+1 data packets are allocated and sent for q of the USB devices; wherein, p+q=m, xp+(x+1)q=y, x=[y / m], and y is equal to the number of sending nodes currently in the filling state.

[0105] In some implementations of the embodiments of the present invention, the sending unit 304 is specifically used to: When the number of sending nodes in the filling state is greater than or equal to n*m, n data packets are allocated and sent to each USB device; wherein m is the number of the USB devices; When the number of sending nodes in the filling state is less than n*m, and the number of sending nodes in the filling state plus the number of remaining applied sending nodes is greater than or equal to n*m, wait until the number of sending nodes in the filling state is greater than or equal to n*m, and allocate and send n data packets to each of the USB devices; When the number of sending nodes in the filling state is less than n*m, and the number of sending nodes in the filling state plus the remaining number of applied sending nodes is less than n*m, when all sending nodes are filled, x data packets are allocated and sent for p of the USB devices, and x+1 data packets are allocated and sent for q of the USB devices; wherein, p+q=m, xp+(x+1)q=y, x=[y / m], and y is equal to the number of sending nodes in the filling state when all sending nodes are filled.

[0106] In some implementations of the embodiments of the present invention, the sending unit 304 is specifically used to: When the number of sending nodes in the filling state is greater than or equal to n*m, n data packets are allocated and sent to each USB device; wherein m is the number of the USB devices; When the number of sending nodes in the filling state is greater than or equal to s*m and less than n*m, x' data packets are allocated and sent for p' USB devices, and x'+1 data packets are allocated and sent for q' USB devices; wherein p'+q'=m, x'p'+(x'+1)q'=y', x'=[y / m], y' is equal to the number of sending nodes currently in the filling state; wherein s≥2; When the number of sending nodes in the filling state is less than s*m, s data packets are allocated and sent for p'' USB devices, and r data packets are allocated and sent for 1 USB device; wherein, sp''+r=y', r≤s.

[0107] In some implementations of the embodiments of the present invention, the sending unit 304 is specifically used to: When the number of sending nodes in the filling state is greater than or equal to n*m, n data packets are allocated and sent to each USB device; wherein m is the number of the USB devices; When the number of sending nodes in the filling state is less than n*m, and the number of sending nodes in the filling state plus the number of remaining applied sending nodes is greater than or equal to n*m, wait until the number of sending nodes in the filling state is greater than or equal to n*m, and allocate and send n data packets to each of the USB devices; When the number of sending nodes in the filling state is less than n*m, and the number of sending nodes in the filling state plus the number of remaining sending nodes that have been applied for is greater than or equal to s*m and less than n*m, when all sending nodes are filled, x' data packets are allocated and sent for p' USB devices, and x'+1 data packets are allocated and sent for q' USB devices; wherein p'+q'=m, x'p'+(x'+1)q'=y', x'=[y / m], y' is equal to the number of sending nodes in the filling state when all sending nodes are filled; wherein s≥2; When the number of sending nodes in the filling state plus the number of remaining applied sending nodes is less than s*m, when all sending nodes are filled, s data packets are allocated and sent for p'' USB devices, and r data packets are allocated and sent for 1 USB device; wherein, sp''+r=y', r≤s.

[0108] In some implementations of the embodiments of the present invention, the number of the preset sending queues is multiple, and the pending data with the same processing requirements are allocated to the sending nodes in the same preset sending queue, and the pending data with different processing requirements are allocated to the sending nodes in different preset sending queues.

[0109] In some implementations of the embodiments of the present invention, the sending unit 304 is specifically used to execute, for each preset sending queue, in a preset order, and to evenly send the to-be-processed data filled into the sending node to each of the USB devices, and each preset sending queue sends the to-be-processed data of a preset length each time.

[0110] In some implementations of the embodiments of the present invention, the host is a multi-core processor, and the number of cores of the multi-core processor is equal to the number of preset sending queues; the sending unit 304 is specifically used to independently execute, for each preset sending queue, the to-be-processed data filled into the sending node to be sent to each of the USB devices in a balanced manner, and each preset sending queue sends the to-be-processed data of a preset length each time.

[0111] In some implementations of the embodiments of the present invention, the allocation unit 302 is further configured to: Allocate a receiving node in a preset receiving queue to each node application request; wherein the sending node in the preset sending queue and the receiving node in the preset receiving queue are in a one-to-one correspondence, the preset receiving queue reuses the preset sending queue, or the preset receiving queue does not reuse the preset sending queue; The receiving unit 305 is further configured to: The calculation result data is parsed and filled into the corresponding receiving node, so that each user can obtain the calculation result data from the receiving node in parallel.

[0112] In some implementation manners of the embodiments of the present invention, the receiving unit 305 is specifically used for: Poll each of the USB devices to obtain the calculation result data in each of the USB devices.

[0113] In some implementations of the embodiments of the present invention, the data to be processed filled in the sending node is sent to each of the USB devices in a balanced manner, including: The driver program obtains the data to be processed in the sending node, and uses a preset data structure to evenly send the obtained data to be processed to each of the USB devices; Obtaining the operation result data fed back by each of the USB devices, including: The driver program obtains the operation result data fed back by each of the USB devices.

[0114] In some implementations of the embodiments of the present invention, the filling unit 303 is specifically used for: The to-be-processed data of each user and the corresponding sending node identifier are encapsulated in parallel according to a preset communication protocol, and the encapsulated to-be-processed data is filled into the corresponding sending node through a unique device file node; wherein the device file node is generated by the driver.

[0115] In some implementation manners of the embodiments of the present invention, the receiving unit 305 is further configured to: For any data to be processed, if the operation result data fed back by the external device is not received within the preset time period, the acquisition unit 301 is called again to execute the step of acquiring the node application request corresponding to the data to be processed.

[0116] In some implementations of the embodiments of the present invention, each sending node fills a data packet, and the preset size matches the single-packet data length supported by the USB device.

[0117] In some implementations of the embodiments of the present invention, when the user is an application program and there are multiple data to be processed, the process of the user initiating a node application request includes: The user initiates node application requests for each piece of data to be processed; or, The user creates multiple threads, each of which initiates a node application request; or, Alternatively, the user merges multiple data to be processed into one data to be processed and initiates a node application request.

[0118] In some implementations of the embodiments of the present invention, the applied sending nodes are continuous, and the data packets sent to each of the USB devices originate from the continuous sending nodes.

[0119] In some implementations of the embodiments of the present invention, each of the USB devices is mounted on a PCIE bus and is communicatively connected to the host via a same PCIE interface.

[0120] Those skilled in the art can clearly understand that the technology in the embodiments of the present invention can be implemented by means of software plus a necessary general hardware platform. Based on this understanding, the technical solution in the embodiments of the present invention can be essentially or partly contributed to the prior art in the form of a software product, which can be stored in a storage medium such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in the various embodiments of the present invention or certain parts of the embodiments.

[0121] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other. In the absence of conflict, the embodiments of the present invention and the features in the embodiments can be combined with each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system and device embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.

[0122] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein, for example. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0123] The above-described embodiments of the present invention do not constitute a limitation on the protection scope of the present invention. Any modification, equivalent replacement and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A data transmission method, characterized in that: Applied to a host, the host is communicatively connected with a plurality of USB devices, the method comprising: Obtain multiple node application requests, wherein each node application request is initiated by a user; Allocate the sending nodes in the preset sending queue to each node application request; In parallel, the to-be-processed data of each user and the corresponding sending node identifier are encapsulated according to a preset communication protocol, and the encapsulated to-be-processed data is filled into the corresponding sending node; Sending the to-be-processed data filled into the sending node to each of the USB devices in a balanced manner; Obtaining the operation result data fed back by each of the USB devices; wherein the operation result data includes a receiving node identifier, and the sending node identifier and the receiving node identifier correspond one to one.

2. The method according to claim 1, characterized in that In parallel, each user's to-be-processed data and the corresponding sending node identifier are encapsulated according to a preset communication protocol, and the encapsulated to-be-processed data is filled into the corresponding sending node, including: The data to be processed of each user is divided in parallel, each divided data and the corresponding sending node identifier are encapsulated into a data packet of a preset size according to a preset communication protocol, and the data packet is filled into the corresponding sending node; The method includes: sending the to-be-processed data filled in the sending node to each of the USB devices in a balanced manner, including: The data packets filled in the sending node are sent to each USB device in a balanced manner; wherein the number of data packets sent to each USB device each time is at most n, and n is determined according to the maximum cache data volume of the data received by the USB device and the preset size.

3. The method according to claim 2, characterized in that The data packets filled in the sending node are sent to each of the USB devices in a balanced manner, including: When the number of sending nodes in the filling state is greater than or equal to n*m, n data packets are allocated and sent to each USB device; wherein m is the number of the USB devices; When the number of sending nodes in the filling state is less than n*m, x data packets are allocated and sent for p of the USB devices, and x+1 data packets are allocated and sent for q of the USB devices; wherein p+q=m, xp+(x+1)q=y, x=[y / m], and y is equal to the number of sending nodes currently in the filling state; or, The data packets filled in the sending node are sent to each of the USB devices in a balanced manner, including: When the number of sending nodes in the filling state is greater than or equal to n*m, n data packets are allocated and sent to each USB device; wherein m is the number of the USB devices; When the number of sending nodes in the filling state is less than n*m, and the number of sending nodes in the filling state plus the number of remaining applied sending nodes is greater than or equal to n*m, wait until the number of sending nodes in the filling state is greater than or equal to n*m, and allocate and send n data packets to each of the USB devices; When the number of sending nodes in the filling state is less than n*m, and the number of sending nodes in the filling state plus the remaining number of applied sending nodes is less than n*m, when all sending nodes are filled, x data packets are allocated and sent for p of the USB devices, and x+1 data packets are allocated and sent for q of the USB devices; wherein, p+q=m, xp+(x+1)q=y, x=[y / m], and y is equal to the number of sending nodes in the filling state when all sending nodes are filled.

4. The method according to claim 2, characterized in that: The data packets filled in the sending node are sent to each of the USB devices in a balanced manner, including: When the number of sending nodes in the filling state is greater than or equal to n*m, n data packets are allocated and sent to each USB device; wherein m is the number of the USB devices; When the number of sending nodes in the filling state is greater than or equal to s*m and less than n*m, x' data packets are allocated and sent for p' USB devices, and x'+1 data packets are allocated and sent for q' USB devices; wherein p'+q'=m, x'p'+(x'+1)q'=y', x'=[y / m], y' is equal to the number of sending nodes currently in the filling state; wherein s≥2; When the number of sending nodes in the filling state is less than s*m, s data packets are allocated and sent for p'' USB devices, and r data packets are allocated and sent for 1 USB device; wherein sp''+r=y', r≤s; or, The data packets filled in the sending node are sent to each of the USB devices in a balanced manner, including: When the number of sending nodes in the filling state is greater than or equal to n*m, n data packets are allocated and sent to each USB device; wherein m is the number of the USB devices; When the number of sending nodes in the filling state is less than n*m, and the number of sending nodes in the filling state plus the number of remaining applied sending nodes is greater than or equal to n*m, wait until the number of sending nodes in the filling state is greater than or equal to n*m, and allocate and send n data packets to each of the USB devices; When the number of sending nodes in the filling state is less than n*m, and the number of sending nodes in the filling state plus the number of remaining sending nodes that have been applied for is greater than or equal to s*m and less than n*m, when all sending nodes are filled, x' data packets are allocated and sent for p' USB devices, and x'+1 data packets are allocated and sent for q' USB devices; wherein p'+q'=m, x'p'+(x'+1)q'=y', x'=[y / m], y' is equal to the number of sending nodes in the filling state when all sending nodes are filled; wherein s≥2; When the number of sending nodes in the filling state plus the number of remaining applied sending nodes is less than s*m, when all sending nodes are filled, s data packets are allocated and sent for p'' USB devices, and r data packets are allocated and sent for 1 USB device; wherein, sp''+r=y', r≤s.

5. The method according to claim 1, characterized in that There are multiple preset sending queues, and the to-be-processed data with the same processing requirement are allocated to the sending nodes in the same preset sending queue, and the to-be-processed data with different processing requirements are allocated to the sending nodes in different preset sending queues.

6. The method according to claim 5, characterized in that For each preset sending queue, the step of evenly sending the data to be processed filled in the sending node to each USB device is performed in a preset order, and each preset sending queue sends the data to be processed of a preset length each time.

7. The method according to claim 1, characterized in that The method further comprises: Allocate a receiving node in a preset receiving queue to each node application request; wherein the sending node in the preset sending queue and the receiving node in the preset receiving queue are in a one-to-one correspondence, the preset receiving queue reuses the preset sending queue, or the preset receiving queue does not reuse the preset sending queue; Parsing the calculation result data and filling the calculation result data into the corresponding receiving node; Each user obtains the calculation result data from the receiving node in parallel.

8. The method according to claim 1, characterized in that The method includes: sending the to-be-processed data filled in the sending node to each of the USB devices in a balanced manner, including: The driver program obtains the data to be processed in the sending node, and uses a preset data structure to evenly send the obtained data to be processed to each of the USB devices; Obtaining the operation result data fed back by each of the USB devices, including: The driver program obtains the operation result data fed back by each of the USB devices.

9. The method according to claim 8, characterized in that In parallel, each user's to-be-processed data and the corresponding sending node identifier are encapsulated according to a preset communication protocol, and the encapsulated to-be-processed data is filled into the corresponding sending node, including: The to-be-processed data of each user and the corresponding sending node identifier are encapsulated in parallel according to a preset communication protocol, and the encapsulated to-be-processed data is filled into the corresponding sending node through a unique device file node; wherein the device file node is generated by the driver.

10. A data transmission device, characterized in that: Applied to a host, the host is communicatively connected with a plurality of USB devices, the device comprises: An acquisition unit, used to acquire multiple node application requests, wherein each node application request is initiated by a user; An allocating unit, used to allocate a sending node in a preset sending queue to each node application request; A filling unit, used to encapsulate the to-be-processed data of each user and the corresponding sending node identifier in parallel according to a preset communication protocol, and fill the encapsulated to-be-processed data into the corresponding sending node; A sending unit, used for sending the to-be-processed data filled in the sending node to each of the USB devices in a balanced manner; The receiving unit is used to obtain the operation result data fed back by each of the USB devices; wherein the operation result data includes a receiving node identifier, and the sending node identifier and the receiving node identifier correspond one to one.