CN111221751A - Method and system for improving usb batch transmission speed in Linux system - Google Patents

Method and system for improving usb batch transmission speed in Linux system Download PDF

Info

Publication number
CN111221751A
CN111221751A CN202010031010.7A CN202010031010A CN111221751A CN 111221751 A CN111221751 A CN 111221751A CN 202010031010 A CN202010031010 A CN 202010031010A CN 111221751 A CN111221751 A CN 111221751A
Authority
CN
China
Prior art keywords
urb
usb
requests
transmission speed
label
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.)
Granted
Application number
CN202010031010.7A
Other languages
Chinese (zh)
Other versions
CN111221751B (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 ZHONGFU TAIHE TECHNOLOGY DEVELOPMENT CO LTD
Nanjing Zhongfu Information Technology Co Ltd
Zhongfu Information Co Ltd
Zhongfu Safety Technology Co Ltd
Original Assignee
BEIJING ZHONGFU TAIHE TECHNOLOGY DEVELOPMENT CO LTD
Nanjing Zhongfu Information Technology Co Ltd
Zhongfu Information Co Ltd
Zhongfu Safety Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by BEIJING ZHONGFU TAIHE TECHNOLOGY DEVELOPMENT CO LTD, Nanjing Zhongfu Information Technology Co Ltd, Zhongfu Information Co Ltd, Zhongfu Safety Technology Co Ltd filed Critical BEIJING ZHONGFU TAIHE TECHNOLOGY DEVELOPMENT CO LTD
Priority to CN202010031010.7A priority Critical patent/CN111221751B/en
Publication of CN111221751A publication Critical patent/CN111221751A/en
Application granted granted Critical
Publication of CN111221751B publication Critical patent/CN111221751B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

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/10Program control for peripheral devices
    • G06F13/102Program control for peripheral devices where the programme performs an interfacing function, e.g. device driver
    • 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/40Bus structure
    • G06F13/4063Device-to-bus coupling
    • G06F13/4068Electrical coupling
    • 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/0042Universal serial bus [USB]
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

A method for improving usb batch transmission speed in a Linux system comprises the following steps: sending a plurality of urb requests; filling a circulation label in usercontext of a struct usbdevfs _ urb structure; calling an ioctl function for receiving data, and receiving result data urb transmitted by the system; the loop label of usercontext passed back urb; the multiple urb requests continue to be sent using the looping label. The embodiment of the invention also comprises a system for improving the usb batch transmission speed in the Linux system. There are multiple urb requests in the urb queue of the system, and multiple usb data packets are transmitted on the corresponding usb bus, so that on one hand, the bus utilization rate is improved, and the system can communicate with the usb device as soon as possible, on the other hand, urb requests occur in the queue in batches at one time, and usb data packets also exist in the bus where the usb device is located in batches, so that the system and hardware can preferentially process the usb transmission requests and post-process the requests of other usb devices, and the transmission speed of the usb device is improved.

Description

Method and system for improving usb batch transmission speed in Linux system
Technical Field
The invention relates to the technical field of communication transmission, in particular to a method and a system for improving usb batch transmission speed in a Linux system.
Background
There are two ways for the Linux system to access the usb device: writing a kernel driving module ko and writing a program in a user space, and accessing the usb device through the usbfs function provided by the kernel. Writing the user space program has many advantages over the kernel module (the user program has many optional libraries for development, is convenient to develop, has less influence on the system than the kernel module, and does not cause the whole system to crash because of program errors, etc.), so more and more people select the user space program to write the usb device driver to access the usb device. Under the Linux system, the usb driver of the user space is generally selected to be written using the libusb open source library (http:// libusb. info).
The libussb serves as a general usb library and supports multi-platform use (windows, Linux, OS X and the like), because multiple platforms and multiple use modes need to be considered, the libussb library has the situation that performance cannot meet requirements under the environment with strict requirements on certain conditions, and efficiency is not high when mass transmission needs to be performed and a large amount of data needs to be sent and received quickly.
Disclosure of Invention
The invention aims to provide a method and a system for improving usb batch transmission speed in a Linux system, which are used for solving the problem of low transmission efficiency when data is transmitted in batches.
The technical scheme adopted by the invention for solving the technical problems is as follows:
the invention provides a method for improving usb batch transmission speed in a Linux system, which comprises the following steps:
sending a plurality of urb requests;
filling a circulation label in usercontext of a struct usbdevfs _ urb structure;
calling an ioctl function for receiving data, and receiving result data urb transmitted by the system;
the loop label of usercontext passed back urb;
the multiple urb requests continue to be sent using the looping label.
With reference to the first aspect, in a first possible implementation manner of the first aspect, in the above method, the number of urb requests in the urb request queue remains unchanged.
The second aspect of the invention provides a system for increasing usb batch transmission speed in a Linux system, which comprises a request module, a transmission module and a transmission module, wherein the request module is used for sending urb requests; and/or the presence of a gas in the gas,
the calling module is used for calling the ioctl function to obtain result data urb transmitted by the system; and/or the presence of a gas in the gas,
and the circulation label module is used for filling a circulation label in usercontext of the struct usbdevfs-urb structure.
With reference to the second aspect, in a first possible implementation manner of the second aspect, the value of the cyclic index ranges from 1 to 800.
As can be seen from the above description, in the present invention, multiple urb requests are available in an urb queue of a system, and multiple usb data packets are transmitted on the corresponding usb bus, so that on one hand, the bus utilization rate is improved, and the system can communicate with usb devices as soon as possible, and on the other hand, urb requests occur in a queue in batches at a time, and usb data packets also occur in a large batch in the bus where the usb device is located, so that the system and hardware can preferentially process the usb transmission request and post-process requests of other usb devices, thereby improving the transmission speed of the usb device.
Drawings
In order to more clearly illustrate the embodiments or technical solutions in the prior art of the present invention, the drawings used in the description of the embodiments or prior art will be briefly described below, and it is obvious for those skilled in the art that other drawings can be obtained based on these drawings without creative efforts.
FIG. 1 is a schematic flow chart of a method for increasing usb batch transmission speed in a Linux system;
fig. 2 is a schematic structural diagram of a system for increasing usb batch transmission speed in a Linux system according to an embodiment of the present invention.
Detailed Description
In order to make those skilled in the art better understand the technical solution of the present invention, the technical solution in the embodiment of the present invention will be clearly and completely described below with reference to the drawings in the embodiment of the present invention, and it is obvious that the described embodiment is only a part of the embodiment of the present invention, and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
At present, a general method for accessing usb equipment by a user space program under Linux is as follows:
the method for realizing the access of the user space program to the usb device by the usbfs driver provided by the Linux kernel.
And 2, usb equipment is accessed, and the usbfs creates a character equipment node of the equipment under/dev/bus/usb: the bus is a bus number of usb, and the DDD is a device number assigned to the device by the system.
3. The application program traverses (or uses a hot plug mechanism to obtain a bus number and a device number for direct access)/dev/bus/usb directory, uses a system call open to open/dev/bus/usb/BBB/DDD devices, and uses a read system call to read usb device descriptors, configuration descriptors, interface descriptors and the like of the devices, so as to confirm whether the devices need to be operated.
4. An ioctl system call is used for sending usb endpoint (endpoint) I/O requests or carrying out other types of device operations, and batch transmission needs to encapsulate an urb request (usbdevfs _ urb structural body). The request and read results are sent urb using ioctl.
#define USBDEVFS_SUBMITURB_IOR('U',10,struct usbdevfs_urb)
#define USBDEVFS_REAPURBNDELAY_IOW('U',13,void*)
ioctl(fd,IOCTL_USBFS_SUBMITURB,struct usbdevfs_urb*)
ioctl(fd,IOCTL_USBFS_REAPURBNDELAY,struct usbdevfs_urb*)
Wherein, USBDEVFS _ SUBMITURB sends request (asynchronization) to usb device,
the USBDEVFS _ READURNDELAY returns a result for reading the usb device.
5. And after receiving the data, the USBFS implementation part (linux src-x.x.xx/drivers/usb/core/device.c) of the kernel converts the data into urb data format used by the kernel layer, puts the urb request into the request queue, and ends the IOCTL _ USBFS _ SUBMITURB call.
6. The urb request data is processed by the usb core and then delivered to a corresponding Host Controller Driver (HCD) (host control device driver), the HCD processes the request urb obtained from the corresponding usb endpoint queue, interacts with the actual usb device, fills a urb structural body after the request is finished, transfers the data layer by layer, and finally reaches/dev/usb/BBB/DDD, and reads the result of the request through IOCTL _ USBFS _ repurbndelay.
The above is a process of one-time universal usb request transmission by using the libussb library, only one urb request is sent at a time, and the result of one urb request is read, so that the method is not efficient when usb equipment has good performance and needs to quickly send and receive a large amount of data for batch transmission. Therefore, the invention provides a method and a system for improving usb batch transmission speed in a Linux system.
As shown in fig. 1, a method for increasing usb batch transmission speed in a Linux system includes the following steps:
s1, sending a plurality of urb requests;
s2, filling a circulation label in usercontext of the struct usbdevfs-urb structure;
s3, calling an ioctl function for receiving data, and receiving result data urb transmitted by the system;
s4, returning urb cycle index of usercontext;
s5, continue sending multiple urb requests with the looping label.
The urb request number in the urb request queue in the system is kept unchanged, so that a plurality of urb requests are available in the urb queue of the system, and a plurality of usb data packets are transmitted on the corresponding usb bus, so that on one hand, the bus utilization rate is improved, and the system can communicate with usb equipment as soon as possible, on the other hand, the urb requests are batched in the queue at one time, and the usb data packets are also batched in the bus where the usb equipment is located, so that the system and hardware can preferentially process the usb transmission request and post-process the requests of other usb equipment, and the transmission speed of the usb equipment is improved.
As shown in fig. 2, an embodiment of the present invention further provides a system for increasing usb batch transmission speed in a Linux system, where the system includes a request module, configured to send urb a request; the calling module is used for calling the ioctl function to obtain result data urb transmitted by the system; and the circulation label module is used for filling a circulation label in usercontext of the struct usbdevfs-urb structure. The value range of the cyclic label is 1-800, and the value can be adjusted according to the actual situation so as to improve the maximum transmission speed and avoid influencing the communication of other usb devices of the machine to be optimal.
The foregoing are merely exemplary embodiments of the present invention, which enable those skilled in the art to understand or practice the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (4)

1. A method for improving usb batch transmission speed in a Linux system is characterized by comprising the following steps:
sending a plurality of urb requests;
filling a circulation label in usercontext of a struct usbdevfs _ urb structure;
calling an ioctl function for receiving data, and receiving result data urb transmitted by the system;
the loop label of usercontext passed back urb;
the multiple urb requests continue to be sent using the looping label.
2. The method of claim 1, wherein the number of urb requests in the urb request queue remains unchanged in the method.
3. A system for increasing usb batch transmission speed in a Linux system, using the method of any one of claims 1-2, wherein the system comprises a request module for sending urb a request; and/or the presence of a gas in the gas,
the calling module is used for calling the ioctl function to obtain result data urb transmitted by the system; and/or the presence of a gas in the gas,
and the circulation label module is used for filling a circulation label in usercontext of the struct usbdevfs-urb structure.
4. The system of claim 3, wherein the cyclic index has a value in the range of 1-800.
CN202010031010.7A 2020-01-13 2020-01-13 Method and system for improving usb batch transmission speed in Linux system Active CN111221751B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010031010.7A CN111221751B (en) 2020-01-13 2020-01-13 Method and system for improving usb batch transmission speed in Linux system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010031010.7A CN111221751B (en) 2020-01-13 2020-01-13 Method and system for improving usb batch transmission speed in Linux system

Publications (2)

Publication Number Publication Date
CN111221751A true CN111221751A (en) 2020-06-02
CN111221751B CN111221751B (en) 2023-10-27

Family

ID=70829420

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010031010.7A Active CN111221751B (en) 2020-01-13 2020-01-13 Method and system for improving usb batch transmission speed in Linux system

Country Status (1)

Country Link
CN (1) CN111221751B (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090222841A1 (en) * 2008-03-03 2009-09-03 Moschip Semiconductor Technology Limited Acceleration of receive data throughput of a usb device
CN102082968A (en) * 2010-10-29 2011-06-01 广东星海数字家庭产业技术研究院有限公司 Multi-hardware compatible bluetooth device driving system
WO2016161749A1 (en) * 2015-04-10 2016-10-13 中兴通讯股份有限公司 Data transmission method, device and system
CN108170289A (en) * 2018-01-22 2018-06-15 郑州云海信息技术有限公司 The driving method of keyboard is customized based on USB
CN109117390A (en) * 2018-08-09 2019-01-01 山东中孚安全技术有限公司 A kind of Linux kernel module obtains the method and system of usb_bus_type symbolic address
CN109426643A (en) * 2017-08-25 2019-03-05 中兴通讯股份有限公司 USB interface request scheduling method, device and equipment
CN110598428A (en) * 2019-08-22 2019-12-20 中国电子科技集团公司第二十八研究所 USB (Universal Serial bus) equipment management and control system based on Linux user space

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090222841A1 (en) * 2008-03-03 2009-09-03 Moschip Semiconductor Technology Limited Acceleration of receive data throughput of a usb device
CN102082968A (en) * 2010-10-29 2011-06-01 广东星海数字家庭产业技术研究院有限公司 Multi-hardware compatible bluetooth device driving system
WO2016161749A1 (en) * 2015-04-10 2016-10-13 中兴通讯股份有限公司 Data transmission method, device and system
CN109426643A (en) * 2017-08-25 2019-03-05 中兴通讯股份有限公司 USB interface request scheduling method, device and equipment
CN108170289A (en) * 2018-01-22 2018-06-15 郑州云海信息技术有限公司 The driving method of keyboard is customized based on USB
CN109117390A (en) * 2018-08-09 2019-01-01 山东中孚安全技术有限公司 A kind of Linux kernel module obtains the method and system of usb_bus_type symbolic address
CN110598428A (en) * 2019-08-22 2019-12-20 中国电子科技集团公司第二十八研究所 USB (Universal Serial bus) equipment management and control system based on Linux user space

Also Published As

Publication number Publication date
CN111221751B (en) 2023-10-27

Similar Documents

Publication Publication Date Title
CN109976925B (en) Method and system based on mixed multi-system inter-core real-time communication
CN106951388B (en) PCIe-based DMA data transmission method and system
US6070194A (en) Using an index and count mechanism to coordinate access to a shared resource by interactive devices
KR100352224B1 (en) Direct memory access(dma) transactions on a low pin count bus
US20120303846A1 (en) Method for implementing audio transmission and mobile terminal
CN113296884B (en) Virtualization method, virtualization device, electronic equipment, virtualization medium and resource virtualization system
KR100309189B1 (en) System input/output interface design for scaling
CN112749113A (en) Data interaction method, system, device and medium
CN112947857B (en) Data moving method, device, equipment and computer readable storage medium
CN114925012A (en) Ethernet frame issuing method, Ethernet frame uploading method and related devices
CN112131176B (en) FPGA (field programmable Gate array) quick local reconstruction method based on PCIE (peripheral component interface express)
CN111221751B (en) Method and system for improving usb batch transmission speed in Linux system
CN110971621A (en) Embedded multi-CPU interconnection circuit based on SDIO interface, interconnection method and driving method
CN112199314B (en) Universal USB device cross-platform transparent transmission method based on network
CN113886297A (en) SPI concurrent communication SE device and method based on DMA
CN111443994A (en) Simulation smart card driving program, information interaction system and working method thereof
CN111427823A (en) Drive design method supporting PC and FPGA to communicate through PCIE
CN115277842B (en) Multi-partition network management sinking communication method
CN112835836B (en) Method and device for information interaction between host and smart card
CN111124987B (en) PCIE-based data transmission control system and method
CN110471865B (en) Method for realizing communication between controller and driver by simulating SPI communication
CN109901935B (en) Method and equipment for communicating with USB Key
CN112631975A (en) Linux-based SPI transmission method
KR900001533B1 (en) Control device for synchronized data link control
CN112347024A (en) USB data transmission optimization method and system

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