CN116232779A - USB network card, data transmission method and device and readable storage medium - Google Patents

USB network card, data transmission method and device and readable storage medium Download PDF

Info

Publication number
CN116232779A
CN116232779A CN202310160078.9A CN202310160078A CN116232779A CN 116232779 A CN116232779 A CN 116232779A CN 202310160078 A CN202310160078 A CN 202310160078A CN 116232779 A CN116232779 A CN 116232779A
Authority
CN
China
Prior art keywords
uplink
packet
data
ethernet
circuit
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.)
Pending
Application number
CN202310160078.9A
Other languages
Chinese (zh)
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.)
Wuxi Muchuang Integrated Circuit Design Co ltd
Original Assignee
Wuxi Muchuang Integrated Circuit Design 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 Wuxi Muchuang Integrated Circuit Design Co ltd filed Critical Wuxi Muchuang Integrated Circuit Design Co ltd
Priority to CN202310160078.9A priority Critical patent/CN116232779A/en
Publication of CN116232779A publication Critical patent/CN116232779A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/02Details
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L2212/00Encapsulation of packets

Abstract

The application relates to the technical field of communication and discloses a USB network card, a data transmission method, a device and a readable storage medium, wherein in a USB acceleration circuit of the USB network card, an uplink Ethernet packet is received, packet information of the uplink Ethernet packet is obtained, the uplink Ethernet packet is stored in an uplink data cache unit, and the packet information is stored in an uplink information cache unit; continuously reading out a plurality of frames of uplink Ethernet packets from an uplink data buffer unit by utilizing packet information, and packaging the read out frames of uplink Ethernet packets; and transmitting the packaged uplink Ethernet packet to a host. According to the method and the device, the multi-frame Ethernet packets are packaged and transmitted, so that the bus bandwidth can be utilized to the greatest extent possible, and the bandwidth utilization rate of the data bus is greatly improved.

Description

USB network card, data transmission method and device and readable storage medium
Technical Field
The present invention relates to the field of communications technologies, and in particular, to a USB network card, a data transmission method, a data transmission device, and a readable storage medium.
Background
The traditional USB drive-free network card reports the host to RNDIS or ECM/NCM equipment, then after the host is successfully identified, the host further acquires relevant configuration information of the equipment (if the host is a windows system, the host can additionally acquire the expansion attribute of Microsoft besides the relevant configuration information), and after the host successfully acquires the relevant configuration information, a driver corresponding to the configuration is loaded, so that the USB network card equipment can perform normal data communication with the host.
The USB drive-free network card hardware acceleration method comprises the following steps: the software carrying data part in the traditional USB drive-free network card is realized by hardware, but the traditional hardware method is to transmit one frame of Ethernet data packet (Ethernet packet) at a time, so that the bandwidth utilization rate of a data bus is low.
In summary, how to effectively improve the bandwidth utilization of the data bus is a technical problem that needs to be solved by those skilled in the art.
Disclosure of Invention
The invention aims to provide a USB network card, a data transmission method, a device and a readable storage medium, which can improve the bandwidth utilization rate of a data bus by packing and transmitting multi-frame Ethernet packets.
In order to solve the technical problems, the application provides the following technical scheme:
a USB network card, a USB network card acceleration circuit comprising:
an uplink branch used for transmitting the Ethernet packet generated by the Ethernet module to the host;
the downlink branch is used for transmitting the Ethernet packet sent by the host to the Ethernet module;
in the uplink branch, an uplink data checking circuit is connected with the Ethernet module and the uplink buffer unit and finally is converged into an RNDIS circuit or an NCM circuit; the uplink buffer unit is of a first-in first-out buffer structure, and comprises an uplink data buffer unit and an uplink information buffer unit;
The RNDIS circuit is used for realizing uplink and downlink transmission of an Ethernet packet of an RNDIS protocol; the NCM circuit is used for realizing uplink and downlink transmission of Ethernet packets of an NCM protocol;
in the downlink branch, starting from the RNDIS circuit or the NCM circuit, a downlink data checking circuit is connected with a downlink buffer unit, and the tail end of the downlink data checking circuit is connected with the Ethernet module; the downlink buffer unit is of a first-in first-out buffer structure, and comprises a downlink data buffer unit and a downlink information buffer unit;
and in the uplink branch, transmitting the Ethernet packet generated by the Ethernet module to the host in a multi-packet mode when the multi-packet uplink condition is met according to the current data packet caching condition.
Preferably, in the uplink branch, the ethernet packet after being packed and accelerated by the RNDIS circuit or the NCM circuit is converged into an AHB/AXI bus through a MUX selector;
in the downlink branch, the Ethernet packet analyzed by the RNDIS circuit or the NCM circuit is transmitted to a downlink check circuit through a MUX selector.
Preferably, the RNDIS circuit includes: an upstream sub-circuit and a downstream sub-circuit;
In the uplink sub-circuit, reading data of an uplink buffer unit through a data input processing circuit, packaging and accelerating the read Ethernet packet by a rndis uplink packaging circuit, converting the packaged data into rndis data, and transmitting the rndis data to an AHB/AXI bus connected with the host by a data output processing circuit;
in the downlink sub-circuit, the data of the AHB/AXI bus is read through a data input processing circuit, the rndis downlink unpacking circuit analyzes the read rndis data into a plurality of independent Ethernet packets, and the data output processing circuit sequentially writes the single Ethernet packet into a downlink checking circuit.
Preferably, the NCM circuit includes: an upstream sub-circuit and a downstream sub-circuit;
in the uplink sub-circuit, reading data of the FIFO interface through a data input processing circuit, packaging and accelerating the read Ethernet packet by a ncm uplink packaging circuit, converting the packaged data into ncm data, and transmitting the ncm data to an AHB/AXI bus connected with the host by a data output processing circuit;
in the downlink sub-circuit, data of the AHB/AXI bus is read through a data input processing circuit, a ncm downlink unpacking circuit analyzes ncm data into a plurality of independent Ethernet packets, and a data output processing circuit sequentially writes a single Ethernet packet into a downlink checking circuit.
The data transmission method is applied to the USB network card and comprises the following steps:
receiving an uplink Ethernet packet and acquiring packet information of the uplink Ethernet packet;
storing the uplink Ethernet packet in the uplink data caching unit, and storing the packet information in an uplink information caching unit;
continuously reading out a plurality of frames of the uplink Ethernet packets from the uplink data caching unit by utilizing the packet information, and packaging the read out frames of the uplink Ethernet packets;
and transmitting the packaged uplink Ethernet packet to the host.
Preferably, the uplink ethernet packet is stored in the uplink data buffer unit, and the packet information is stored in the uplink information buffer unit, including:
using the uplink checking circuit to check the uplink Ethernet packet based on the packet information in the uplink information caching unit;
if the check is not passed, discarding the uplink Ethernet packet;
if the check is passed, checking the length of the uplink Ethernet packet;
and after the length check is passed, storing the uplink Ethernet packet in the uplink data caching unit, and storing the packet information in the uplink information caching unit.
Preferably, the method for continuously reading out the uplink ethernet packets of the frames from the uplink data buffer unit by using the packet information, and packaging the read out frames of the uplink ethernet packets, includes:
continuously reading out N frames of uplink Ethernet packets meeting the packaging and encapsulation conditions from the uplink data buffer unit by utilizing the packet information;
and packaging and encapsulating the N frames of uplink Ethernet packets.
Preferably, using the packet information, continuously reading out the uplink ethernet packet with N frames satisfying the packing and encapsulation condition from the uplink data buffer unit, including:
and continuously reading out at least 15 frames of uplink Ethernet packets with the total length smaller than a preset threshold value from the uplink data buffer unit by utilizing the packet size in the packet information.
Preferably, using the packet information, continuously reading out the uplink ethernet packet with N frames satisfying the packing and encapsulation condition from the uplink data buffer unit, including:
and continuously reading out N frames of uplink Ethernet packets with the frame number smaller than 15 and the total length larger than or equal to a preset threshold value from the uplink data buffer unit by utilizing the packet size in the packet information.
Preferably, using the packet information, continuously reading out the uplink ethernet packet with N frames satisfying the packing and encapsulation condition from the uplink data buffer unit, including:
And continuously reading out the residual uplink Ethernet packets with the frame number smaller than 15 and the total length smaller than a preset threshold value from the uplink data buffer unit by utilizing the packet size in the packet information.
Preferably, transmitting the packaged uplink ethernet packet to a host, including:
transmitting the packaged uplink Ethernet packet to a host by using an uplink state machine;
the uplink state machine includes: an uplink initial state, an uplink waiting state, an uplink multi-packet transmission completion state and an uplink multi-packet transmission state;
the uplink initial state corresponds to an initial state after power-on, and if the uplink data caching unit is not empty, the uplink waiting state is skipped;
executing multi-packet uplink condition judgment in the uplink waiting state, requesting the host to read data once transmission is started, and jumping to the uplink multi-packet transmission state if the host generates bus reading to read data; if an uplink multi-frame transmission completion signal exists, jumping to the uplink multi-packet transmission completion state; if the host stays in the state for a long time and the host does not respond, the host jumps to the uplink initial state in a timeout mode;
the uplink multi-packet transmission completion state is skipped to the uplink waiting state if the next multi-packet transmission is continued;
And in the uplink multi-packet transmission state, if the host temporarily stops transmission in the transmission process, the host jumps to the uplink waiting state.
Preferably, the method further comprises:
analyzing the multi-packet sent by the host, and screening out an actual downlink Ethernet packet;
checking the downlink Ethernet packet by using a downlink checking circuit;
after the verification is passed, the downlink Ethernet packet is stored in a downlink data caching unit, and the packet information of the downlink Ethernet packet is stored in a downlink information caching unit.
The data transmission device is applied to the USB network card and comprises:
the packet receiving module is used for receiving the uplink Ethernet packet and acquiring the packet information of the uplink Ethernet packet;
the storage module is used for storing the uplink Ethernet packet in an uplink data caching unit and storing the packet information in an uplink information caching unit;
the packaging module is used for continuously reading out a plurality of frames of the uplink Ethernet packets from the uplink data caching unit by utilizing the packet information, and packaging the read out frames of the uplink Ethernet packets;
and the transmission module is used for transmitting the packaged uplink Ethernet packet to a host.
A readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of the data transmission method described above.
The USB network card acceleration circuit specifically comprises an uplink branch and a downlink branch, and when the uplink branch meets the multi-packet uplink condition, the uplink branch can transmit Ethernet packets generated by the Ethernet module to a host in a multi-packet mode. Compared with the traditional data transmission generally adopts one frame of Ethernet for transmission, so that no matter short packets or long packets are transmitted once, the bus is requested once again, the transmission efficiency is seriously affected, the transmission bandwidth can not be obviously improved, and the multi-frame Ethernet packets are packaged and transmitted, so that the bus bandwidth can be utilized to the greatest extent possible, and the bandwidth utilization rate of the data bus is greatly improved.
The method provided by the embodiment of the application is applied to the USB network card, the uplink Ethernet packet is received, the packet information of the uplink Ethernet packet is obtained, the uplink Ethernet packet is stored in the uplink data caching unit, and the packet information is stored in the uplink information caching unit; continuously reading out a plurality of frames of uplink Ethernet packets from an uplink data buffer unit by utilizing packet information, and packaging the read out frames of uplink Ethernet packets; and transmitting the packaged uplink Ethernet packet to a host.
In the present application, after the USB network card acceleration circuit receives the upstream ethernet packet, packet information of the upstream ethernet packet is first obtained, then the upstream ethernet packet is stored in the upstream data buffer unit, and the packet information is stored in the upstream information buffer unit. Based on the packet information, a plurality of frame uplink Ethernet packets are continuously read out from an uplink data buffer unit, the read out plurality of frame uplink Ethernet packets are packed and encapsulated, and finally the packed and encapsulated uplink Ethernet packets are transmitted to a host. That is, in the present application, the ethernet packet is not transmitted in a single frame form, but several frames of uplink ethernet packets are packaged and encapsulated, and the multi-frame uplink ethernet packet is transmitted at a time. Compared with the traditional data transmission generally adopts one frame of Ethernet for transmission, so that no matter short packets or long packets are transmitted once, the bus is requested once again, the transmission efficiency is seriously affected, the transmission bandwidth can not be obviously improved, and the multi-frame Ethernet packets are packaged and transmitted, so that the bus bandwidth can be utilized to the greatest extent possible, and the bandwidth utilization rate of the data bus is greatly improved.
Accordingly, the embodiments of the present application further provide a data transmission device and a readable storage medium corresponding to the above data transmission method, which have the above technical effects and are not described herein.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the related art, the drawings that are required to be used in the embodiments or the related technical descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and other drawings may be obtained according to the drawings without inventive effort for a person having ordinary skill in the art.
Fig. 1 is a schematic structural diagram of a USB network card according to an embodiment of the present application;
fig. 2 is a schematic diagram of an uplink transmission state machine in the embodiment of the present application;
fig. 3 is a schematic diagram of a downlink transmission state machine in the embodiment of the present application;
FIG. 4 is a schematic diagram of a workflow of a USB network card circuit according to an embodiment of the present application;
FIG. 5 is a schematic diagram of an NCM-based circuit workflow in an embodiment of the present application;
FIG. 6 is a schematic diagram of an RNDIS-based circuit workflow according to an embodiment of the present application;
fig. 7 is a schematic structural diagram of a data transmission device according to an embodiment of the present application;
Fig. 8 is a flowchart of an implementation of a data transmission method in an embodiment of the present application;
fig. 9 is a schematic diagram of an internal circuit structure of a USB network card according to an embodiment of the present application;
FIG. 10 is a schematic diagram of an RNDIS circuit of a USB network card according to an embodiment of the present application;
fig. 11 is a schematic diagram of an NCM circuit in a USB network card according to an embodiment of the present application.
Detailed Description
In order to provide a better understanding of the present application, those skilled in the art will now make further details of the present application with reference to the drawings and detailed description. It will be apparent that the described embodiments are only some, but not all, of the embodiments of the present application. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are within the scope of the present disclosure.
In order to facilitate understanding of the technical solutions described in the embodiments of the present application, the following description will explain related terms:
USB-CDC: the CDC class in the USB protocol is a short term of the USB communication device class (Communication Device Class), the CDC class is a USB subclass defined by the USB organization and dedicated to various communication devices (telecommunication devices and medium speed network communication devices), and the USB-CDC can be divided into several subclasses:
CDC-ECM (Ethernet Networking ControlModel, ethernet control model) ECM protocol enables exchange of ethernet frames between device and host, devices conforming to ECM specifications, considered themselves as a virtual network interface annotated, can be assigned MAC and IP, typically using ECM devices as LAN/WAN adapters;
CDC-NCM (Network Control Model ) NCM protocol is used to exchange high-speed ethernet frames between device and host, devices conforming to ECM specifications, considered themselves to be annotated one virtual network interface, which can be assigned MAC and IP, common devices using NCM are wireless adapters supporting 3.5G/4G networks (e.g., hspa+ and LTE).
The RNDIS (Remote network Driver Interface Specification ) protocol is a variant implementation of microsoft for CDC-ECM, and is mainly used to simplify the driver development of USB network devices in windows platforms.
FIFO (First In First Out) it is a first-in first-out data buffer, and is different from general memory in that it has no external read-write address line, so that it is very simple to use, but its disadvantage is that only data can be written in sequentially, and the data address can be automatically added by 1 by means of internal read-write pointer, and it can not be read or written into a specific address by means of address line.
Referring to fig. 1, fig. 1 is a schematic structural diagram of a USB network card according to an embodiment of the present application. The USB network card comprises the following circuit structures:
an uplink branch used for transmitting the Ethernet packet generated by the Ethernet module to the host;
a downlink branch for transmitting the Ethernet packet sent by the host to the Ethernet module;
in the uplink branch, an uplink data checking circuit is connected with an Ethernet module and an uplink buffer unit and finally is converged into an RNDIS circuit or an NCM circuit; the uplink buffer unit is of a first-in first-out buffer structure and comprises an uplink data buffer unit and an uplink information buffer unit;
the RNDIS circuit is used for realizing uplink and downlink transmission of an Ethernet packet of an RNDIS protocol; the NCM circuit is used for realizing uplink and downlink transmission of Ethernet packets of an NCM protocol;
in the downlink branch, starting from an RNDIS circuit or an NCM circuit, a downlink data checking circuit is connected with a downlink buffer unit, and the tail end of the downlink data checking circuit is connected with an Ethernet module; the downlink buffer unit is of a first-in first-out buffer structure, and comprises a downlink data buffer unit and a downlink information buffer unit;
in the uplink branch, when the multi-packet uplink condition is met, the Ethernet packet generated by the Ethernet module is transmitted to the host in a multi-packet mode.
The buffer unit may be specifically a FIFO, or may be another storage medium having a first-in-first-out performance.
The USB network card specifically comprises an uplink branch and a downlink branch, and when the uplink branch meets the multi-packet uplink condition, the uplink branch can transmit the Ethernet packet generated by the Ethernet module to a host in a multi-packet mode. Compared with the traditional data transmission generally adopts one frame of Ethernet for transmission, so that no matter short packets or long packets are transmitted once, the bus is requested once again, the transmission efficiency is seriously affected, the transmission bandwidth can not be obviously improved, and the multi-frame Ethernet packets are packaged and transmitted, so that the bus bandwidth can be utilized to the greatest extent possible, and the bandwidth utilization rate of the data bus is greatly improved.
In a specific embodiment of the present application, please refer to fig. 9, fig. 9 is a schematic circuit diagram of a USB network card according to an embodiment of the present application.
In the uplink branch, the Ethernet packet after being packed and accelerated by the RNDIS circuit or the NCM circuit is converged into an AHB/AXI bus through a MUX selector;
in the downlink branch, the Ethernet packet analyzed by the RNDIS circuit or the NCM circuit is transmitted to the downlink check circuit through the MUX selector.
Wherein, data uplink: the USB network card acceleration circuit receives data from the Ethernet, writes the data into the data FIFO and the information FIFO after passing through the uplink check circuit, and then sends the data in the FIFO into the RNDIS circuit and the NCM circuit for Ethernet packet processing and packet acceleration.
And (3) data downlink: the USB network card accelerating circuit receives USB packets from a USB Core, the RNDIS circuit and the NCM circuit analyze the received USB packets into Ethernet packets, and because the network card only works in one mode (because the operating system of the host is determined) within a certain time, the analyzed Ethernet packets are written into the downlink check circuit through the MUX selector, and the Ethernet packets processed by the downlink check circuit are rewritten into the data FIFO and the information FIFO.
Ethernet data interface (connected to ethernet module): for receiving (transmitting) ethernet packets from the ethernet module.
And an uplink checking circuit: and checking the uplink Ethernet packet to ensure that the data written into the FIFO is correct, and enabling an RNDIS (NCM) circuit to realize packet acceleration.
Upper (lower) data FIFO: and storing the Ethernet packet processed by the checking circuit.
Upper (lower) line information FIFO: and storing the Ethernet packet information processed by the checking circuit.
And a downlink checking circuit: and checking the downlink Ethernet packet to ensure that the data written into the FIFO is correct for the Ethernet module to read.
A MUX selector: and a data selector of 2-1 is realized, and data is screened according to the information provided by software enumeration.
RNDIS circuit: the hardware circuit for realizing RNDIS protocol comprises an uplink sub-circuit and a downlink sub-circuit, wherein the uplink circuit comprises an Ethernet packet acceleration (conversion) function, and the downlink circuit comprises an RNDIS packet analysis function.
NCM circuit: the hardware circuit for realizing the NCM comprises an uplink sub-circuit and a downlink sub-circuit, wherein the uplink circuit comprises an Ethernet packet acceleration (conversion) function, and the downlink circuit comprises a NCM packet analysis function.
Data bus (software): the software interface mainly interacts with the software to process some information, for example, the software can tell the USB network card acceleration circuit of the operating system information in the enumeration process, so that the MUX circuit can select or the USB network card circuit can also tell the software to process when interrupt information is generated.
Data bus (USB Core): for receiving (transmitting) USB packets from the USB Core.
Referring to fig. 10 and 11, fig. 10 is a schematic circuit diagram of RNDIS in a USB network card according to an embodiment of the present application, and fig. 11 is a schematic circuit diagram of NCM in a USB network card according to an embodiment of the present application; that is, the RNDIS circuit includes: an upstream sub-circuit and a downstream sub-circuit;
in the uplink sub-circuit, reading data of an uplink buffer unit through a data input processing circuit, packaging and accelerating the read Ethernet packet by a rndis uplink packaging circuit, converting the packaged data into rndis data, and transmitting the rndis data to an AHB/AXI bus connected with a host by a data output processing circuit;
in the downlink sub-circuit, data of an AHB/AXI bus is read through a data input processing circuit, the rndis downlink unpacking circuit analyzes the read rndis data into a plurality of independent Ethernet packets, and the data output processing circuit sequentially writes a single Ethernet packet into a downlink checking circuit.
That is, the RNDIS circuit includes two sub-circuits of up (down) row, which operate separately, do not affect each other, and the sub-circuits of up row: firstly, correctly reading data of a FIFO interface through a data input processing circuit, then, packaging and accelerating a read Ethernet packet by an rndis uplink packaging circuit based on the method provided by the patent, converting the packaged data into rndis data, and finally, transmitting the rndis data to an AHB/AXI bus through the data output processing circuit; the whole uplink sub-circuit is controlled by an uplink state machine; a downlink subcircuit: firstly, data of an AHB/AXI bus is correctly read through a data input processing circuit, then rndis downlink unpacking circuit can analyze the rndis data into multiple (or single) independent Ethernet packets, and finally the data output processing circuit can successively write the single Ethernet packet into a downlink checking circuit; the entire downstream subcircuit is controlled by a downstream state machine.
NCM circuitry comprising: an upstream sub-circuit and a downstream sub-circuit;
in the uplink sub-circuit, reading data of the FIFO interface through a data input processing circuit, packaging the read Ethernet packet by a ncm uplink packaging circuit, converting the packaged data into ncm data, and transmitting ncm data to an AHB/AXI bus connected with a host by a data output processing circuit;
in the downlink sub-circuit, data of the AHB/AXI bus is read through a data input processing circuit, the ncm data is analyzed into a plurality of independent Ethernet packets by a ncm downlink unpacking circuit, and the data output processing circuit sequentially writes the single Ethernet packet into a downlink checking circuit.
That is, the NCM circuit includes two sub-circuits of the up (down) row, which operate separately and do not affect each other, wherein the up sub-circuits: firstly, correctly reading data of a FIFO interface through a data input processing circuit, then, carrying out packaging acceleration on the read Ethernet packet by a ncm uplink packaging circuit based on the method provided by the patent, converting the packaged data into ncm data, and finally, transmitting ncm data to an AHB/AXI bus through a data output processing circuit, wherein the whole uplink sub-circuit is controlled by an uplink state machine; a downlink subcircuit: firstly, data of an AHB/AXI bus is correctly read through a data input processing circuit, then ncm data are analyzed into multiple (or single) independent Ethernet packets by a ncm downlink unpacking circuit, and finally, the single Ethernet packet is written into a downlink checking circuit by a data output processing circuit successively, and the whole downlink sub-circuit is controlled by a downlink state machine.
Referring to fig. 8, fig. 8 is a flowchart of a data transmission method according to an embodiment of the present application, and the method can be applied to a USB network card (USB network card device). For USB network card devices, the communication requirements can be basically met by adopting RNDIS (Remote network Driver Interface Specification ) or NCM (Network Control Model, network control model) protocols (note: NCM is an upgrade-enhanced version of ECM, and is also a specification belonging to USB CDC) facing different mainstream operating systems (Linux, windows, mac OS, etc.), and the protocols support larger-capacity data transmission. The circuit structure of the USB network card is shown in fig. 1.
Wherein, the uplink data buffer unit: a data buffer structure in the form of a queue, which is mainly used for storing each received uplink data packet;
an uplink information caching unit: the uplink data caching unit is a parallel caching structure and is mainly used for storing relevant information of each received uplink data packet, such as the length of the data packet, a packet correct error mark and the like;
a downlink information caching unit: a data buffer structure in the form of a queue, which is mainly used for storing each downlink data packet to be sent to an external network;
A downlink data caching unit: the downlink data buffer unit is a parallel buffer structure and is mainly used for storing the related information of each received downlink data packet, such as the length of the data packet, the packet correct error mark and the like;
RNDIS circuit: a hardware circuit module for realizing RNDIS protocol transmission;
NCM circuit: a hardware circuit module for realizing NCM protocol transmission;
data verification circuit (up verification circuit and down verification circuit): and the data buffer unit is used for judging whether the uplink (downlink) data packet is correct, writing the data packet into the data buffer unit if the uplink (downlink) data packet is correct, updating the corresponding information buffer unit, and discarding the data packet if the uplink (downlink) data packet is incorrect.
Specifically, the data transmission method comprises the following steps:
s101, receiving an uplink Ethernet packet and acquiring packet information of the uplink Ethernet packet.
The USB drive-free network card can receive an uplink Ethernet packet through the Ethernet module, and can acquire packet information of the uplink Ethernet packet through analyzing the uplink Ethernet packet, wherein the packet information can specifically comprise the length of an Ethernet frame and an information cache unit (such as a marking bit for marking whether the Ethernet frame is in error or not).
S102, storing the uplink Ethernet packet in an uplink data caching unit, and storing packet information in an uplink information caching unit.
The uplink data buffer unit and the uplink information buffer unit are two parallel buffer structures, and the two buffer structures are respectively used for storing different data contents, so that the buffer structure for storing uplink Ethernet packets is called an uplink data buffer unit, and the buffer structure for storing packet information of the uplink Ethernet packets is called an uplink information buffer unit.
In an optional implementation manner in the present application, the storage may be further performed after the verification, and the specific implementation process includes:
storing the uplink ethernet packet in the uplink data buffer unit, storing packet information in the uplink information buffer unit, including:
step one, utilizing an uplink checking circuit to check an uplink Ethernet packet based on packet information in an uplink information caching unit;
step two, if the verification is not passed, discarding the uplink Ethernet packet;
step three, if the check is passed, checking the length of the uplink Ethernet packet;
and step four, after the length check is passed, storing the uplink Ethernet packet in an uplink data caching unit, and storing packet information in an uplink information caching unit.
In uplink transmission, because the NCM (or RNDIS circuit) adopts a multi-packet transmission mechanism and combines with the buffer unit first-in first-out principle, it can be known that once a certain frame data in the multi-packet is in error, uplink transmission error is caused, and thus data cannot be normally transmitted. Therefore, before writing into the data buffer unit, a data check circuit (uplink check circuit) may be added, where the uplink check circuit performs a check (including ethernet frame length comparison, CRC check, information buffer unit, etc.) on the externally input ethernet packet. The verification is mainly divided into two stages. The downlink process corresponds to this.
Firstly, judging the content of information buffer unit, if error is reported, directly discarding correspondent frame of Ethernet packet,
and step two, performing secondary verification based on the step one confirmation, including performing Ethernet packet length comparison according to the information frame content, performing CRC verification according to the Ethernet packet content, and the like.
And finally, writing the uplink Ethernet packet which passes the verification of the two stages into an uplink data caching unit, and updating the corresponding uplink information caching unit.
Correspondingly, during downlink transmission, the NCM (RNDIS) circuit analyzes multiple packets transmitted by the bus, and writes the packets into the downlink data caching unit after the packets pass through the data checking circuit, and updates the corresponding downlink information caching unit.
S103, using the packet information, continuously reading out a plurality of frames of uplink Ethernet packets from the uplink data caching unit, and packaging and encapsulating the read out frames of uplink Ethernet packets.
In uplink transmission, because the uplink data buffer unit can store multi-frame ethernet packets, the simplest mode is to send the multi-frame ethernet packets frame by frame, but the utilization rate of the data bus is not very high. How to package and send the Ethernet packets in the data buffer unit, so that the transmission rate can be improved, and the correctness of the data can be ensured, is a problem to be solved at present.
In the application, multi-packet transmission is adopted so as to improve transmission efficiency and ensure data correctness. Specifically, a multi-packet acceleration method is utilized to continuously read out a plurality of frame uplink ethernet packets from an uplink data buffer unit, and then the read out plurality of frame uplink ethernet packets are packaged and encapsulated. I.e. multiple frames (2 frames and more than 2 frames) are included and combined into one data packet.
Specifically, in one specific embodiment of the present application, using packet information, a plurality of frames of upstream ethernet packets are continuously read from an upstream data buffer unit, and the read frames of upstream ethernet packets are packaged and encapsulated, including:
continuously reading out N frames of uplink Ethernet packets meeting packaging and encapsulation conditions from an uplink data buffer unit by utilizing packet information;
and step two, packaging and encapsulating the N frames of uplink Ethernet packets.
For convenience of description, the two steps are described in combination.
That is, in the present application, a packing condition may be set, and N frames of uplink ethernet packets meeting the packing condition may be continuously read out from the uplink data buffer unit by using the packet information, and then the N frames of uplink ethernet packets are packed and encapsulated.
Specifically, the packing and packaging conditions may be set based on the total length and the number of frames read out.
That is, the first step may specifically be: and continuously reading out at least 15 frames of uplink Ethernet packets with the total length smaller than a preset threshold value from the uplink data buffer unit by utilizing the packet size in the packet information. The preset threshold may be specifically a maximum length that can be transmitted by the transmission protocol.
The first step may be specifically: and continuously reading out N frames of uplink Ethernet packets with the frame number of more than or equal to 15 and the total length of more than or equal to a preset threshold value from an uplink data buffer unit by utilizing the packet size in the packet information. That is, an upper frame number limit (which may be matched with the transmission protocol specification used) may be set, and the upper frame number limit may be 15 or another number greater than 15, and when the number of consecutive frames reaches the upper frame number limit and the total length is greater than or equal to the preset threshold, the packet transmission may be performed.
When some uplink ethernet packets have larger lengths, it may happen that the number of frames does not reach the upper transmission limit, and the total length is greater than or equal to a preset threshold, and packaging and encapsulation can be performed at this time. That is, the first step may be specifically: and continuously reading all uplink Ethernet packets with the frame number smaller than 15 and the total length larger than a preset threshold value by using the packet size in the packet information from the uplink data buffer unit.
In addition, when 15 frames cannot be read out and the total length is smaller than the preset threshold value, all the remaining uplink ethernet packets in the uplink data buffer unit are read out, and at this time, packaging and encapsulation can be performed.
For example, based on a particular transport protocol, the packaging encapsulation conditions may include:
1. condition 1: the method can continuously read out 15 frames of Ethernet packets from an uplink data buffer unit, and the total length of the 15 frames of Ethernet packets is smaller than 14.4KB;
2. condition 2: it is satisfied that N frames of ethernet packets (N < 15) can be continuously read out from the upstream data buffer unit, and the total length of the N frames of ethernet packets is 14.4KB or more.
Since USB3.0 supports up to 16KB transmission at most a single time, and one frame ethernet has a maximum length of 1548 bytes, and RNDIS data also needs to be added with header 44 bytes of information, 1592 bytes are added in total, so the maximum preset threshold for RNDIS multi-packet transmission can be set to about 14.4KB (16 KB-1.548 KB), and once the threshold of condition 2 is exceeded, one RNDIS multi-packet transmission can be started.
3. Condition 3: the condition that N frames of ethernet packets can be continuously read out from the upstream data buffer unit is satisfied, and neither condition 1 nor condition 2 is satisfied.
S104, transmitting the packaged uplink Ethernet packet to a host.
After packaging, the upstream ethernet packets may be transmitted to the host in multiple packets.
Specifically, the packed uplink ethernet packet may be transmitted to the host based on the ECM module or the RNDIS module. Whether the ECM module or RNDIS module is used in particular may be determined during the USB enumeration process.
USB enumeration is the initialization of USB. In short, a dialogue between the host (host) and the device (device), i.e. the host knows what type of device is, what function the device has, based on the parameters reported by the device, and then initializes the relevant parameters. After a series of operations, the device can work normally. So, it can be simply understood that USB enumeration, i.e. initialization of a USB device.
USB enumeration can be divided into 4 phases:
1. access state phase: resetting the bus (releasing the bus in an idle state) after the host detects that the new device is accessed;
2. default state phase: the host accesses the newly accessed device by using the 0x00 address, and after reading part of the descriptor, the host allocates the device address;
3. address state phase: resetting the bus again by the host computer, and then acquiring all descriptors of the equipment by using the newly allocated address;
4. Setting a state stage: the host will make relevant configurations for the device based on the device's descriptor.
How NCM and RNDIS distinguish during enumeration is described below:
in the third stage of USB enumeration, when the host obtains all descriptors of the device, an NCM code, such as 0Dh (specifically Network Control Model), is included in the interface descriptor, so that the device can be described as an NCM device after corresponding modification in the code, and the host sends data according to the NCM data protocol.
RNDIS is similar to the above, and is also the third stage, the modified descriptor content is RNDIS over Ethernet, and the code is modified correspondingly. After the enumeration of the RNDIS is successful, the RNDIS needs to be initialized, and parameters need to be modified in the initialization process, so that the host knows that the device can send data through multiple packets. Specifically, in the initialization process, the maximum number of continuous packets (the parameter is modified to 0x0000000 f) of a single bus transmission needs to be modified in the step of rndis_init_cmplt, the maximum length of a single bus transmission (the sum of all byte numbers of the maximum packet, the parameter is modified to 0x00005c 94), and byte alignment (16 byte alignment, and the parameter is modified to 0x 00000004) during multi-packet transmission, so that data can be transmitted between the host and the device in a multi-packet mode.
To properly schedule data transmission, a state machine (FSM) may be employed for control. That is, transmitting the packaged uplink ethernet packet to the host includes: and transmitting the packaged uplink Ethernet packet to the host by using a state machine.
Referring to fig. 2, fig. 2 is a schematic diagram of an uplink transmission state machine in an embodiment of the present application.
idle: in the initial state after power-up, pop_eth is to read data once the upstream data cache unit is not empty, and jump to the tx_usb_standby state
tx_usb_standby: and (5) uplink transmission Ethernet data waiting state, and executing three judgment conditions of uplink transmission in the state. Once the transfer is initiated, the host is requested to read the data. The host generates ahb _rb to read the data and jumps to the tx_usb_pack state; if the tx_done signal is present, indicating that the multi-packet transmission is finished, and jumping to the tx_eth_done state; if the host remains in the idle state for a long time and does not respond, the host overtime jumps to the idle state
tx_eth_done: the up multi-packet transmission completion state continues the next multi-packet transmission and jumps to the tx_usb_standby state
tx_usb_pack: in the uplink multi-packet transmission state, the host may stop transmission temporarily during transmission, and may generate ≡! ahb rd signal, jump to tx_usb_standby state.
By applying the method provided by the embodiment of the application, the method provided by the embodiment of the application is applied to the USB network card, the uplink Ethernet packet is received, the packet information of the uplink Ethernet packet is obtained, the uplink Ethernet packet is stored in the uplink data cache unit, and the packet information is stored in the uplink information cache unit; continuously reading out a plurality of frames of uplink Ethernet packets from an uplink data buffer unit by utilizing packet information, and packaging the read out frames of uplink Ethernet packets; and transmitting the packaged uplink Ethernet packet to a host.
In the application, after the USB network card acceleration circuit in the USB network card receives the uplink ethernet packet, the packet information of the uplink ethernet packet is first obtained, then the uplink ethernet packet is stored in the uplink data buffer unit, and the packet information is stored in the uplink information buffer unit. Based on the packet information, a plurality of frame uplink Ethernet packets are continuously read out from an uplink data buffer unit, the read out plurality of frame uplink Ethernet packets are packed and encapsulated, and finally the packed and encapsulated uplink Ethernet packets are transmitted to a host. That is, in the present application, the ethernet packet is not transmitted in a single frame form, but several frames of uplink ethernet packets are packaged and encapsulated, and the multi-frame uplink ethernet packet is transmitted at a time. Compared with the traditional data transmission generally adopts one frame of Ethernet for transmission, so that no matter short packets or long packets are transmitted once, the bus is re-requested once, the transmission efficiency is seriously affected, the transmission bandwidth can not be obviously improved, and the multi-frame Ethernet packets are packed and transmitted, so that the bus bandwidth can be utilized to the greatest extent possible, and the bandwidth utilization rate of the data bus is greatly improved.
It should be noted that, based on the above embodiments, the embodiments of the present application further provide corresponding improvements. The preferred/improved embodiments relate to the same steps as those in the above embodiments or the steps corresponding to the steps may be referred to each other, and the corresponding advantages may also be referred to each other, so that detailed descriptions of the preferred/improved embodiments are omitted herein.
In one specific embodiment of the present application, the processing of the downstream ethernet packet may specifically include performing the following steps:
analyzing the multi-packet sent by the host, and screening out the actual downlink Ethernet packet.
And step two, checking the downlink Ethernet packet by using a downlink checking circuit.
And step three, after the verification is passed, storing the downlink Ethernet packet in a downlink data caching unit, and storing the packet information of the downlink Ethernet packet in a downlink information caching unit.
After multi-packet analysis sent by the host, the actual downlink Ethernet packet can be screened out. Then, the downlink ethernet packet is checked by using the downlink check circuit, and the specific check process can refer to the check process of the uplink ethernet packet, which is not described in detail herein.
After the verification is passed, the downlink ethernet packet may be stored in the downlink data buffer unit, and accordingly, packet information of the downlink ethernet packet is stored in the downlink data buffer unit.
For the convenience of understanding the data transmission method provided in the present application, the following is exemplified in connection with a specific transmission protocol:
after the enumeration of the USB network card device is successful, the software informs the hardware circuit of what operating system is currently, and the hardware circuit selects an NCM circuit (or an RNDIS circuit) according to the software information. The application provides a data transmission method based on an RNDIS protocol and an NCM protocol, and the working flow of a USB network card circuit is shown in figure 4.
Under Linux (or Mac OS), after enumeration is successful, the USB network card device selects an NCM circuit. The NCM protocol has two data formats of NTB-16 and NTB-32, the difference is that the single data transmission of NTB-16 can reach 64KB, and the single data transmission of NTB-32 can reach 4GB, and the device can select different data formats according to the performance.
During downlink transmission, the NCM circuit analyzes the NTB packet sent by the host, and screens out an actual Ethernet packet; in uplink transmission, the NCM circuit encapsulates a plurality of ethernet packets into NTBs and sends the NTBs to the host. The NCM circuit workflow is shown in fig. 5.
Under Windows system, after the enumeration of USB network card device is successful, selecting RNDIS circuit, then informing the host to support multi-packet transmission by the device in the RNDIS initialization process, so that the host and the device can transmit data in the form of multi-packet preferentially, thereby improving transmission efficiency.
During downlink transmission, the RNDIS circuit analyzes multiple packets sent by the host and screens out actual Ethernet packets; during uplink transmission, the RNDIS circuit encapsulates a plurality of Ethernet packets as much as possible and sends the Ethernet packets to the host. The RNDIS circuit workflow is shown in fig. 6.
Considering that the USB network card is full duplex data transmission, the data uplink state machine and the data downlink state machine are separately designed. This state machine is also one of the core designs of this patent. Since the transport mechanisms are similar, NCM and RNDIS employ the same state machine. Fig. 2 and 3 are state machines corresponding to data uplink and data downlink, respectively.
Referring to fig. 2, the data uplink stage:
idle: in the uplink initial state after power-up, once the uplink data caching unit is not empty, reading data, and jumping to a tx_usb_standby state;
tx_usb_standby: an uplink transmission ethernet data waiting state (uplink waiting state) in which three judgment conditions of uplink transmission are performed. Once the transfer is initiated, the host is requested to read the data. The host generates ahb _rb to read the data and jumps to the tx_usb_pack state; if the tx_done signal is present, indicating that the multi-packet transmission is finished, and jumping to the tx_eth_done state; if the host stays in the state for a long time and does not respond, the host overtime jumps to the idle state;
tx_eth_done: the uplink multi-packet transmission completion state continues to the next multi-packet transmission, and jumps to the tx_usb_standby state;
tx_usb_pack: in the uplink multi-packet transmission state, the host may stop transmission temporarily during transmission, and may generate ≡! ahb rd signal, jump to tx_usb_standby state.
Referring to fig. 3, the data downlink stage:
idle: in the initial state after power-on, if the host sends data to the equipment, a ahb _wr signal is generated, and the host jumps to an rx_usb_pack state;
rx_usb_standby: a downstream USB packet reception waiting state in which if a host ahb _wr signal is received, a jump is made to an rx_usb_pack state; if the host computer finishes one-time transmission and generates an rx_done signal, jumping to an rx_eth_done state; if the host stays in the state for a long time and does not respond, the host jumps to the idle state overtime;
rx_eth_done: a downlink multi-packet transmission completion state, if the host continues the next multi-packet transmission and ahb _wr is generated, the host jumps to an rx_usb_pack state;
rx_usb_pack: in the downlink multi-packet transmission state, the host may stop transmission temporarily during transmission, and may generate ≡! ahb _wr signal, then jump to the rx_usb_standby state.
From the above analysis, the conventional data transmission generally uses a frame-by-frame ethernet to transmit, so that no matter a short packet or a long packet is transmitted, a bus will be requested again as long as one transmission is generated, which seriously wastes transmission efficiency and cannot significantly improve transmission bandwidth. Based on the transmission characteristics of RNDIS (or NCM) protocol, a plurality of Ethernet packets can be packed and transmitted, and simultaneously bus bandwidth is utilized to the greatest extent in the packing process, so that the bandwidth utilization rate of a data bus is greatly improved.
Corresponding to the above method embodiments, the embodiments of the present application further provide a data transmission device, where the data transmission device described below and the data transmission method described above may be referred to correspondingly.
Referring to fig. 7, the apparatus includes the following modules:
a packet receiving module 101, configured to receive an uplink ethernet packet and obtain packet information of the uplink ethernet packet;
a storage module 102, configured to store an uplink ethernet packet in an uplink data buffer unit, and store packet information in an uplink information buffer unit;
a packaging module 103, configured to continuously read out a plurality of frames of uplink ethernet packets from the uplink data buffer unit by using the packet information, and package the read out frames of uplink ethernet packets;
And the transmission module 104 is configured to transmit the packaged uplink ethernet packet to the host.
By applying the device provided by the embodiment of the application, the uplink Ethernet packet is received in the USB network card acceleration circuit, the packet information of the uplink Ethernet packet is obtained, the uplink Ethernet packet is stored in the uplink data caching unit, and the packet information is stored in the uplink information caching unit; continuously reading out a plurality of frames of uplink Ethernet packets from an uplink data buffer unit by utilizing packet information, and packaging the read out frames of uplink Ethernet packets; and transmitting the packaged uplink Ethernet packet to a host.
In the present application, after the USB network card acceleration circuit receives the upstream ethernet packet, packet information of the upstream ethernet packet is first obtained, then the upstream ethernet packet is stored in the upstream data buffer unit, and the packet information is stored in the upstream information buffer unit. Based on the packet information, a plurality of frame uplink Ethernet packets are continuously read out from an uplink data buffer unit, the read out plurality of frame uplink Ethernet packets are packed and encapsulated, and finally the packed and encapsulated uplink Ethernet packets are transmitted to a host. That is, in the present application, the ethernet packet is not transmitted in a single frame form, but several frames of uplink ethernet packets are packaged and encapsulated, and the multi-frame uplink ethernet packet is transmitted at a time. Compared with the traditional data transmission generally adopts one frame of Ethernet for transmission, so that no matter short packets or long packets are transmitted once, the bus is requested once again, the transmission efficiency is seriously affected, the transmission bandwidth can not be obviously improved, and the multi-frame Ethernet packets are packaged and transmitted, so that the bus bandwidth can be utilized to the greatest extent possible, and the bandwidth utilization rate of the data bus is greatly improved.
In one specific embodiment of the present application, the storage module 102 is specifically configured to perform verification based on the packet information uplink ethernet packet in the uplink information cache unit;
if the check is not passed, discarding the uplink Ethernet packet;
if the check is passed, checking the length of the uplink Ethernet packet;
after the length check is passed, the uplink Ethernet packet is stored in the uplink data buffer unit, and the packet information is stored in the uplink information buffer unit.
In a specific embodiment of the present application, the packaging module 103 is specifically configured to continuously read out, from the uplink data buffer unit, N frames of uplink ethernet packets that meet a packaging and packaging condition by using the packet information;
and packaging and encapsulating the N frames of uplink Ethernet packets.
In a specific embodiment of the present application, the packetizing module 103 is specifically configured to continuously read out at least 15 frames of upstream ethernet packets with a total length smaller than a preset threshold from the upstream data buffer unit by using a packet size in the packet information.
In a specific embodiment of the present application, the packetizing module 103 is specifically configured to continuously read, from the upstream data buffer unit, N-frame upstream ethernet packets having a frame number less than 15 and a total length greater than or equal to a preset threshold value by using a packet size in the packet information.
In a specific embodiment of the present application, the packetizing module 103 is specifically configured to continuously read out, from the upstream data buffer unit, the remaining upstream ethernet packets having a frame number less than 15 and a total length less than a preset threshold value by using the packet size in the packet information.
In a specific embodiment of the present application, the transmission module 104 is specifically configured to transmit the packaged uplink ethernet packet to the host by using an uplink state machine;
the uplink state machine includes: an uplink initial state, an uplink waiting state, an uplink multi-packet transmission completion state and an uplink multi-packet transmission state;
the uplink initial state corresponds to the initial state after power-on, and if the uplink data caching unit is not empty, the uplink waiting state is skipped;
executing multi-packet uplink condition judgment in an uplink waiting state, requesting a host to read data once transmission is started, and jumping to an uplink multi-packet transmission state if the host generates bus reading to read the data; if the uplink multi-frame transmission completion signal exists, jumping to an uplink multi-packet transmission completion state; if the host stays in the state for a long time and does not respond, the host jumps to the uplink initial state overtime;
the uplink multi-packet transmission completion state is that if the next multi-packet transmission is continued, the state is jumped to the uplink waiting state;
In the uplink multi-packet transmission state, if the host temporarily stops transmission during the transmission, the host jumps to the uplink waiting state.
In a specific embodiment of the present application, further comprising:
the downlink processing module is used for analyzing the multi-packet sent by the host and screening out the actual downlink Ethernet packet;
a downlink check circuit is utilized to check the downlink Ethernet packet;
after the verification is passed, storing the downlink Ethernet packet in a downlink data caching unit, and storing packet information of the downlink Ethernet packet in a downlink information caching unit;
and sending the downlink Ethernet packet in the downlink data caching unit by using the packet information.
Corresponding to the above method embodiments, the embodiments of the present application further provide a readable storage medium, where a readable storage medium described below and a data transmission method described above may be referred to correspondingly.
A readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of the data transmission method of the above method embodiments.
The readable storage medium may be a usb disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a magnetic disk, or an optical disk, and the like.
In this specification, each embodiment is described in a progressive manner, and each embodiment is mainly described in a different point from other embodiments, so that the same or similar parts between the embodiments are referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant points refer to the description of the method section.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative elements and steps are described above generally in terms of functionality in order to clearly illustrate the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Those skilled in the art may implement the described functionality using different approaches for each particular application, but such implementation should not be considered to be beyond the scope of this application.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. The software modules may be disposed in Random Access Memory (RAM), memory, read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
Finally, it is further noted that, in this document, relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms include, comprise, or any other variation is intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus.
The principles and embodiments of the present application are described herein with specific examples, the above examples being provided only to assist in understanding the methods of the present application and their core ideas; meanwhile, as those skilled in the art will vary in the specific embodiments and application scope according to the ideas of the present application, the contents of the present specification should not be construed as limiting the present application in summary.

Claims (14)

1. A USB network card, wherein the USB network card acceleration circuit comprises:
An uplink branch used for transmitting the Ethernet packet generated by the Ethernet module to the host;
the downlink branch is used for transmitting the Ethernet packet sent by the host to the Ethernet module;
in the uplink branch, an uplink data checking circuit is connected with the Ethernet module and the uplink buffer unit and finally is converged into an RNDIS circuit or an NCM circuit; the uplink buffer unit is of a first-in first-out buffer structure, and comprises an uplink data buffer unit and an uplink information buffer unit;
the RNDIS circuit is used for realizing uplink and downlink transmission of an Ethernet packet of an RNDIS protocol; the NCM circuit is used for realizing uplink and downlink transmission of Ethernet packets of an NCM protocol;
in the downlink branch, starting from the RNDIS circuit or the NCM circuit, a downlink data checking circuit is connected with a downlink buffer unit, and the tail end of the downlink data checking circuit is connected with the Ethernet module; the downlink buffer unit is of a first-in first-out buffer structure, and comprises a downlink data buffer unit and a downlink information buffer unit;
and in the uplink branch, transmitting the Ethernet packet generated by the Ethernet module to the host in a multi-packet mode when the multi-packet uplink condition is met according to the current data packet caching condition.
2. The USB network card of claim 1, wherein in the upstream leg, ethernet packets packed and accelerated by the RNDIS circuit or the NCM circuit are converged into an AHB/AXI bus through a MUX selector;
in the downlink branch, the Ethernet packet analyzed by the RNDIS circuit or the NCM circuit is transmitted to a downlink check circuit through a MUX selector.
3. The USB network card of claim 1, wherein the RNDIS circuit comprises: an upstream sub-circuit and a downstream sub-circuit;
in the uplink sub-circuit, reading data of an uplink buffer unit through a data input processing circuit, packaging and accelerating the read Ethernet packet by a rndis uplink packaging circuit, converting the packaged data into rndis data, and transmitting the rndis data to an AHB/AXI bus connected with the host by a data output processing circuit;
in the downlink sub-circuit, the data of the AHB/AXI bus is read through a data input processing circuit, the rndis downlink unpacking circuit analyzes the read rndis data into a plurality of independent Ethernet packets, and the data output processing circuit sequentially writes the single Ethernet packet into a downlink checking circuit.
4. The USB network card of claim 1, wherein the NCM circuit includes: an upstream sub-circuit and a downstream sub-circuit;
in the uplink sub-circuit, reading data of the FIFO interface through a data input processing circuit, packaging and accelerating the read Ethernet packet by a ncm uplink packaging circuit, converting the packaged data into ncm data, and transmitting the ncm data to an AHB/AXI bus connected with the host by a data output processing circuit;
in the downlink sub-circuit, data of the AHB/AXI bus is read through a data input processing circuit, a ncm downlink unpacking circuit analyzes ncm data into a plurality of independent Ethernet packets, and a data output processing circuit sequentially writes a single Ethernet packet into a downlink checking circuit.
5. A data transmission method, applied to the USB network card according to any one of claims 1 to 4, comprising:
receiving an uplink Ethernet packet and acquiring packet information of the uplink Ethernet packet;
storing the uplink Ethernet packet in the uplink data caching unit, and storing the packet information in an uplink information caching unit;
Continuously reading out a plurality of frames of the uplink Ethernet packets from the uplink data caching unit by utilizing the packet information, and packaging the read out frames of the uplink Ethernet packets;
and transmitting the packaged uplink Ethernet packet to the host.
6. The data transmission method according to claim 5, wherein storing the upstream ethernet packet in the upstream data buffer unit and storing the packet information in the upstream information buffer unit includes:
using the uplink checking circuit to check the uplink Ethernet packet based on the packet information in the uplink information caching unit;
if the check is not passed, discarding the uplink Ethernet packet;
if the check is passed, checking the length of the uplink Ethernet packet;
and after the length check is passed, storing the uplink Ethernet packet in the uplink data caching unit, and storing the packet information in the uplink information caching unit.
7. The data transmission method according to claim 5, wherein reading out a plurality of frames of the upstream ethernet packets from the upstream data buffer unit in succession using the packet information, and packaging the read out frames of the upstream ethernet packets, comprises:
Continuously reading out N frames of uplink Ethernet packets meeting the packaging and encapsulation conditions from the uplink data buffer unit by utilizing the packet information;
and packaging and encapsulating the N frames of uplink Ethernet packets.
8. The data transmission method according to claim 7, wherein continuously reading out, from the upstream data buffer unit, the upstream ethernet packets of which N frames satisfy a packing encapsulation condition using the packet information, comprises:
and continuously reading out at least 15 frames of uplink Ethernet packets with the total length smaller than a preset threshold value from the uplink data buffer unit by utilizing the packet size in the packet information.
9. The data transmission method according to claim 8, wherein continuously reading out, from the upstream data buffer unit, the upstream ethernet packets of which N frames satisfy a packing encapsulation condition using the packet information, comprises:
and continuously reading out N frames of uplink Ethernet packets with the frame number smaller than 15 and the total length larger than or equal to a preset threshold value from the uplink data buffer unit by utilizing the packet size in the packet information.
10. The data transmission method according to claim 7, wherein continuously reading out, from the upstream data buffer unit, the upstream ethernet packets of which N frames satisfy a packing encapsulation condition using the packet information, comprises:
And continuously reading out the residual uplink Ethernet packets with the frame number smaller than 15 and the total length smaller than a preset threshold value from the uplink data buffer unit by utilizing the packet size in the packet information.
11. The method for transmitting data according to claim 5, wherein transmitting the upstream ethernet packet after being packed to the host includes:
transmitting the packaged uplink Ethernet packet to a host by using an uplink state machine;
the uplink state machine includes: an uplink initial state, an uplink waiting state, an uplink multi-packet transmission completion state and an uplink multi-packet transmission state;
the uplink initial state corresponds to an initial state after power-on, and if the uplink data caching unit is not empty, the uplink waiting state is skipped;
executing multi-packet uplink condition judgment in the uplink waiting state, requesting the host to read data once transmission is started, and jumping to the uplink multi-packet transmission state if the host generates bus reading to read data; if an uplink multi-frame transmission completion signal exists, jumping to the uplink multi-packet transmission completion state; if the host stays in the state for a long time and the host does not respond, the host jumps to the uplink initial state in a timeout mode;
The uplink multi-packet transmission completion state is skipped to the uplink waiting state if the next multi-packet transmission is continued;
and in the uplink multi-packet transmission state, if the host temporarily stops transmission in the transmission process, the host jumps to the uplink waiting state.
12. The data transmission method according to claim 5, further comprising:
analyzing the multi-packet sent by the host, and screening out an actual downlink Ethernet packet;
checking the downlink Ethernet packet by using a downlink checking circuit;
after the verification is passed, the downlink Ethernet packet is stored in a downlink data caching unit, and the packet information of the downlink Ethernet packet is stored in a downlink information caching unit.
13. A data transmission device, characterized in that it is applied to a USB network card according to any one of claims 1 to 4, and comprises:
the packet receiving module is used for receiving the uplink Ethernet packet and acquiring the packet information of the uplink Ethernet packet;
the storage module is used for storing the uplink Ethernet packet in an uplink data caching unit and storing the packet information in an uplink information caching unit;
the packaging module is used for continuously reading out a plurality of frames of the uplink Ethernet packets from the uplink data caching unit by utilizing the packet information, and packaging the read out frames of the uplink Ethernet packets;
And the transmission module is used for transmitting the packaged uplink Ethernet packet to a host.
14. A readable storage medium, characterized in that the readable storage medium has stored thereon a computer program which, when executed by a processor, implements the steps of the data transmission method according to any of claims 5 to 12.
CN202310160078.9A 2023-02-24 2023-02-24 USB network card, data transmission method and device and readable storage medium Pending CN116232779A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310160078.9A CN116232779A (en) 2023-02-24 2023-02-24 USB network card, data transmission method and device and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310160078.9A CN116232779A (en) 2023-02-24 2023-02-24 USB network card, data transmission method and device and readable storage medium

Publications (1)

Publication Number Publication Date
CN116232779A true CN116232779A (en) 2023-06-06

Family

ID=86586931

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310160078.9A Pending CN116232779A (en) 2023-02-24 2023-02-24 USB network card, data transmission method and device and readable storage medium

Country Status (1)

Country Link
CN (1) CN116232779A (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101668752B1 (en) * 2015-06-23 2016-10-24 한국항공대학교산학협력단 The method and apparatus for inserting additional information field in ethernet frame
CN107395396A (en) * 2017-06-22 2017-11-24 中国科学院西安光学精密机械研究所 The double network interfaces of redundancy based on FPGA can configure Ethernet IP kernel
CN114844842A (en) * 2022-05-07 2022-08-02 湖南戎腾网络科技有限公司 Data transmission method and device, electronic equipment and readable storage medium
CN114925012A (en) * 2022-02-28 2022-08-19 苏州浪潮智能科技有限公司 Ethernet frame issuing method, Ethernet frame uploading method and related devices
CN115280739A (en) * 2020-03-11 2022-11-01 Abb瑞士股份有限公司 Transmitting messages from industrial terminal equipment over an Ethernet network
CN115499505A (en) * 2022-11-18 2022-12-20 无锡沐创集成电路设计有限公司 USB network card and communication method

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101668752B1 (en) * 2015-06-23 2016-10-24 한국항공대학교산학협력단 The method and apparatus for inserting additional information field in ethernet frame
CN107395396A (en) * 2017-06-22 2017-11-24 中国科学院西安光学精密机械研究所 The double network interfaces of redundancy based on FPGA can configure Ethernet IP kernel
CN115280739A (en) * 2020-03-11 2022-11-01 Abb瑞士股份有限公司 Transmitting messages from industrial terminal equipment over an Ethernet network
CN114925012A (en) * 2022-02-28 2022-08-19 苏州浪潮智能科技有限公司 Ethernet frame issuing method, Ethernet frame uploading method and related devices
CN114844842A (en) * 2022-05-07 2022-08-02 湖南戎腾网络科技有限公司 Data transmission method and device, electronic equipment and readable storage medium
CN115499505A (en) * 2022-11-18 2022-12-20 无锡沐创集成电路设计有限公司 USB network card and communication method

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
樊晓东;: "EPON宽带接入系统在商业楼宇接入中的应用", 电信快报, no. 10 *

Similar Documents

Publication Publication Date Title
US10015117B2 (en) Header replication in accelerated TCP (transport control protocol) stack processing
US6954806B2 (en) Data transfer apparatus and method
US11941449B2 (en) Ethernet data stream recording method and system for high-speed data acquisition system
US7561573B2 (en) Network adaptor, communication system and communication method
EP4050491A1 (en) Method for converting avalon bus into axi4 bus
JP3127523B2 (en) Communication control device and data transmission method
CN113961494B (en) Bridging system of PCIE bus and AXI bus
US8626963B2 (en) Packet based data transfer system and method for host-slave interface
CN115499505B (en) USB network card and communication method
CN110941582B (en) USB bus structure of BMC chip and communication method thereof
JP2009502072A (en) FlexRay communication module, FlexRay communication control device, and method for transmitting a message between a FlexRay communication connection and a FlexRay subscriber device
US20100228901A1 (en) Input output control apparatus with a plurality of ports and single protocol processing circuit
CN115622896A (en) AXI4 high-speed bus and multi-queue simulation verification method and simulation verification device
US9288163B2 (en) Low-latency packet receive method for networking devices
KR101197294B1 (en) Method for communication of interface device in SoC-based system network for QoS and improvement of transfer efficiency
CN116232779A (en) USB network card, data transmission method and device and readable storage medium
US20160085683A1 (en) Data receiving device and data receiving method
CN102420749A (en) Device and method for realizing network card issuing function
CN112804027B (en) Data packet generation method and device and data reading method and device
CN114490459A (en) Data transmission method, device, equipment, receiver and storage medium
CN109756517B (en) High-speed network data transmission method based on winpcap
JP5772132B2 (en) Data transfer apparatus, data transfer method, and information processing apparatus
CN107317773B (en) On-chip network communication interface and communication method
CN116795763B (en) Method, system on chip and chip for data packet transmission based on AXI protocol
CN116893987B (en) Hardware acceleration method, hardware accelerator and hardware acceleration 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