CN114826907B - PCIe RC and EP mode switching method, device, equipment and medium - Google Patents

PCIe RC and EP mode switching method, device, equipment and medium Download PDF

Info

Publication number
CN114826907B
CN114826907B CN202210428764.5A CN202210428764A CN114826907B CN 114826907 B CN114826907 B CN 114826907B CN 202210428764 A CN202210428764 A CN 202210428764A CN 114826907 B CN114826907 B CN 114826907B
Authority
CN
China
Prior art keywords
mode
equipment
pcie
environment variable
tree
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202210428764.5A
Other languages
Chinese (zh)
Other versions
CN114826907A (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.)
Xi'an Guanghetong Wireless Communication Co ltd
Original Assignee
Xi'an Guanghetong Wireless Communication 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 Xi'an Guanghetong Wireless Communication Co ltd filed Critical Xi'an Guanghetong Wireless Communication Co ltd
Priority to CN202210428764.5A priority Critical patent/CN114826907B/en
Publication of CN114826907A publication Critical patent/CN114826907A/en
Application granted granted Critical
Publication of CN114826907B publication Critical patent/CN114826907B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/08Configuration management of networks or network elements
    • H04L41/0803Configuration setting
    • H04L41/0813Configuration setting characterised by the conditions triggering a change of settings
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/08Configuration management of networks or network elements
    • H04L41/0803Configuration setting
    • H04L41/0813Configuration setting characterised by the conditions triggering a change of settings
    • H04L41/0816Configuration setting characterised by the conditions triggering a change of settings the condition being an adaptation, e.g. in response to network events
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/2866Architectures; Arrangements
    • H04L67/30Profiles
    • H04L67/306User profiles
    • 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

The application discloses a PCIe RC and EP mode switching method, device, equipment and medium. The RC and EP mode switching method of PCIe comprises the following steps: reading a root environment variable according to a device starting instruction; judging a PCIe mode according to the root environment variable, wherein the PCIe mode comprises an RC mode or an EP mode; starting a corresponding equipment tree according to the RC mode or the EP mode; acquiring an indication parameter based on a root environment variable, and loading a target drive according to the indication parameter in a kernel loading stage, wherein the target drive comprises an RC mode drive or an EP mode drive; and according to the device tree corresponding to the RC mode and the RC mode drive, or the device tree corresponding to the EP mode and the EP mode drive, finishing PCIe mode setting of the device. The RC and EP mode switching method of PCIe can effectively reduce the production cost of the communication module.

Description

PCIe RC and EP mode switching method, device, equipment and medium
Technical Field
The present application relates to the field of network communications technologies, and in particular, to a PCIe RC and EP mode switching method, apparatus, device, and medium.
Background
Communication modules (including but not limited to wireless communication modules such as 5G and 4G) currently based on embedded Linux support an RC (root complex) mode (master mode) and an EP (endpoint device) mode (slave mode) of a PCIe (Peripheral Component Interconnect Express, high-speed serial computer expansion bus standard) high-speed interface. The RC mode is used to externally connect an extension device (PHY (physical)/LAN (Local Area Network )/Wi-Fi (wireless network communication technology)), and the EP mode is used to connect to an upper computer as a slave device.
The existing application scene of the high-speed network of the 5G communication module is largely used in an RC mode or an EP mode, and different software versions are required to be burnt to realize the functions of the RC mode and the EP mode respectively, so that the production cost of the communication module is greatly increased.
Disclosure of Invention
In view of this, the embodiments of the present application provide a method, an apparatus, a device, and a medium for switching RC and EP modes of PCIe, which are used to solve the problem that the device in the communication module needs to burn different software versions to implement RC mode and EP mode functions respectively, thereby resulting in an excessive production cost of the communication module.
In a first aspect, an embodiment of the present application provides a method for switching RC and EP modes of PCIe, where the method includes:
reading a root environment variable according to a device starting instruction;
judging a PCIe mode according to the root environment variable, wherein the PCIe mode comprises an RC mode or an EP mode;
starting a corresponding equipment tree according to the RC mode or the EP mode;
acquiring an indication parameter based on the root environment variable, and loading a target drive according to the indication parameter in a kernel loading stage, wherein the target drive comprises an RC mode drive or an EP mode drive;
and driving according to the equipment tree corresponding to the RC mode and the RC mode, or finishing the PCIe mode setting of the equipment according to the equipment tree corresponding to the EP mode and the EP mode.
In accordance with aspects and any one of the possible implementations described above, there is further provided an implementation, before the reading of the root environment variable according to the device start-up instruction, the method further includes:
acquiring the equipment tree corresponding to the RC mode and the equipment tree corresponding to the EP mode;
acquiring the RC mode driving and the EP mode driving;
and placing the equipment tree corresponding to the RC mode and the RC mode driver in the same software version, wherein after the equipment is started, the PCIe mode setting of the equipment is completed under the software version.
Aspects and any one of the possible implementations as described above, further provide an implementation, the reading the root environment variable according to the device start-up instruction, including:
acquiring an AT instruction, wherein the AT instruction is sent by external control equipment;
setting the root environment variable of the equipment according to the AT instruction, wherein the root environment variable comprises initial setting parameters for judging the PCIe mode of the equipment;
reading the root environment variable according to a device starting instruction, and acquiring the initial setting parameters;
The opening the corresponding device tree according to the RC mode or the EP mode comprises the following steps:
and according to the initial setting parameters, determining that the equipment is in the RC mode or the EP mode, and starting the corresponding equipment tree.
In the aspect and any possible implementation manner described above, there is further provided an implementation manner, where the obtaining, based on the root environment variable, an indication parameter, and loading, in a kernel loading stage, a target driver according to the indication parameter, where the implementation manner includes:
transmitting an indication parameter through Bootarg according to the root environment variable, wherein the indication parameter is used for indicating the PCIe mode adopted by the equipment;
and in the kernel loading stage, the kernel invokes the indication parameters transmitted by Bootarg through an installation function, and loads the target drive according to the indication parameters.
In the aspect and any possible implementation manner described above, there is further provided an implementation manner, where the performing, according to the device tree corresponding to the RC mode and the RC mode driver, or the device tree corresponding to the EP mode and the EP mode driver, the PCIe mode setting of the device includes:
after the equipment starts the equipment tree corresponding to the RC mode and loads the RC mode drive, determining a first network application rule according to parameters in the RC mode and Bootarg, and completing the RC mode setting of the equipment according to the first network application rule;
And after the equipment starts the equipment tree corresponding to the EP mode and loads the EP mode driver, determining a second network application rule according to the parameters in the EP mode and Bootarg, and finishing the EP mode setting of the equipment according to the second network application rule.
Aspects and any one of the possible implementations as described above, further providing an implementation, the method further including:
and in a production test stage, completing the PCIe mode test of the device by adopting the RC mode.
Aspects and any one of the possible implementations as described above, further providing an implementation, the method further including:
when the PCIe mode is converted, the root environment variable and the indication parameter are changed by acquiring the AT instruction to switch the device from the RC mode to the EP mode or switch the device from the EP mode to the RC mode.
In a second aspect, an embodiment of the present application provides a PCIe RC and EP mode switching device, where the device includes:
the reading module is used for reading the root environment variable according to the equipment starting instruction;
the judging module is used for judging a PCIe mode according to the root environment variable, wherein the PCIe mode comprises an RC mode or an EP mode;
The equipment tree opening module is used for opening the corresponding equipment tree according to the RC mode or the EP mode;
the drive loading module is used for acquiring indication parameters based on the root environment variable, and loading a target drive according to the indication parameters in a kernel loading stage, wherein the target drive comprises RC mode drive or EP mode drive;
and the mode setting module is used for driving according to the equipment tree corresponding to the RC mode and the RC mode, or finishing the PCIe mode setting of the equipment according to the equipment tree corresponding to the EP mode and the EP mode.
Further, the device is also specifically used for:
acquiring the equipment tree corresponding to the RC mode and the equipment tree corresponding to the EP mode;
acquiring the RC mode driving and the EP mode driving;
and placing the equipment tree corresponding to the RC mode and the RC mode driver in the same software version, wherein after the equipment is started, the PCIe mode setting of the equipment is completed under the software version.
Further, the reading module is specifically configured to:
acquiring an AT instruction, wherein the AT instruction is sent by external control equipment;
Setting the root environment variable of the equipment according to the AT instruction, wherein the root environment variable comprises initial setting parameters for judging the PCIe mode of the equipment;
and reading the root environment variable according to the equipment starting instruction, and acquiring the initial setting parameters.
Further, the device tree opening module is specifically further configured to:
and according to the initial setting parameters, determining that the equipment is in the RC mode or the EP mode, and starting the corresponding equipment tree.
Further, the drive loading module is specifically configured to:
transmitting an indication parameter through Bootarg according to the root environment variable, wherein the indication parameter is used for indicating the PCIe mode adopted by the equipment;
and in the kernel loading stage, the kernel invokes the indication parameters transmitted by Bootarg through an installation function, and loads the target drive according to the indication parameters.
Further, the mode setting module is specifically configured to:
after the equipment starts the equipment tree corresponding to the RC mode and loads the RC mode drive, determining a first network application rule according to parameters in the RC mode and Bootarg, and completing the RC mode setting of the equipment according to the first network application rule;
And after the equipment starts the equipment tree corresponding to the EP mode and loads the EP mode driver, determining a second network application rule according to the parameters in the EP mode and Bootarg, and finishing the EP mode setting of the equipment according to the second network application rule.
Further, the device is also specifically used for:
and in a production test stage, completing the PCIe mode test of the device by adopting the RC mode.
Further, the device is also specifically used for:
when the PCIe mode is converted, the root environment variable and the indication parameter are changed by acquiring the AT instruction to switch the device from the RC mode to the EP mode or switch the device from the EP mode to the RC mode.
In a third aspect, an embodiment of the present application provides a terminal device, including a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor, the processor executing the computer-readable instructions to perform the steps of the RC and EP mode switching method of PCIe as set forth in the first aspect.
In a fourth aspect, embodiments of the present application provide a computer-readable storage medium storing computer-readable instructions that, when executed by a processor, implement the steps of the RC and EP mode switching method of PCIe of the first aspect.
In the embodiment of the application, a root environment variable is read according to a device starting instruction, and PCIe is determined to be in an RC mode or an EP mode according to the root environment variable, so that the mode adopted by the device for starting at the time is determined when the device is started; then starting a corresponding equipment tree according to the RC mode or the EP mode to realize corresponding hardware resource support under different modes; and then acquiring an indication parameter based on a root environment variable, loading RC mode driving or EP mode according to the indication parameter in a kernel loading stage to finish driving support for switching different modes in the kernel loading stage, and finally finishing PCIe mode setting of the equipment according to equipment tree corresponding to the RC mode and RC mode driving or equipment tree corresponding to the EP mode and EP mode driving, wherein when the equipment needs to be switched between the RC mode and the EP mode, the corresponding hardware resource support and driving support can be quickly found, so that the equipment in the communication module can be accurately switched to the RC mode or the EP mode after being started. The embodiment of the application can integrate the RC mode and the EP mode in the communication module equipment, and can effectively reduce the problem of overhigh production cost of the communication module.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the embodiments will be briefly described below, it being obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flowchart of a PCIe RC and EP mode switching method in an embodiment of the present application;
FIG. 2 is a flowchart of another PCIe RC and EP mode switching method in an embodiment of the present application;
FIG. 3 is a flowchart of another PCIe RC and EP mode switching method in accordance with an embodiment of the present application;
FIG. 4 is a schematic block diagram of a PCIe RC and EP mode switching device in an embodiment of the present application;
fig. 5 is a schematic diagram of a terminal device in an embodiment of the present application.
Detailed Description
For a better understanding of the technical solution of the present application, the following detailed description of the embodiments of the present application refers to the accompanying drawings.
It should be understood that the described embodiments are merely some, but not all, embodiments of the application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
The terminology used in the embodiments of the application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in this application and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
It should be understood that the term "and/or" as used herein is merely one of the same fields describing the associated object, meaning that there may be three relationships, e.g., a and/or B, may represent: a exists alone, A and B exist together, and B exists alone. In addition, the character "/" herein generally indicates that the front and rear associated objects are an "or" relationship.
It should be understood that although the terms first, second, third, etc. may be used to describe the preset ranges, etc. in the embodiments of the present application, these preset ranges should not be limited to these terms. These terms are only used to distinguish one preset range from another. For example, a first preset range may also be referred to as a second preset range, and similarly, a second preset range may also be referred to as a first preset range without departing from the scope of embodiments of the present application.
Depending on the context, the word "if" as used herein may be interpreted as "at … …" or "at … …" or "in response to a determination" or "in response to detection". Similarly, the phrase "if determined" or "if detected (stated condition or event)" may be interpreted as "when determined" or "in response to determination" or "when detected (stated condition or event)" or "in response to detection (stated condition or event), depending on the context.
FIG. 1 is a flowchart of a PCIe RC and EP mode switching method in an embodiment of the present application. The RC and EP mode switching method of PCIe can be applied to application scenes of high-speed network communication. The RC and EP mode switching method of PCIe can be realized through devices in the communication module. As shown in fig. 1, the method for switching RC and EP modes of PCIe includes the following steps:
s10: and reading the root environment variable according to the device start instruction.
The root environment variable may specifically refer to a uboot environment variable, where the uboot is used for a boot loader of an embedded system, and may support multiple different computer system structures. When the (communication module) device is started, the embodiment of the application can adopt uboot environment variables to enable the device to read the current environment state so as to determine that the subsequent device adopts an RC mode or an EP mode. It will be appreciated that devices in the prior art that are only used in RC mode or EP mode will directly enter a preset mode, and switching between the RC mode and EP mode cannot be achieved in a device. The uboot environment variable adopted by the application can enable the equipment to determine the current environment state in the equipment starting stage, and can adjust the PCIe mode according to the actual requirements of the user.
S20: and judging a PCIe mode according to the root environment variable, wherein the PCIe mode comprises an RC mode or an EP mode.
The root environment variable may specifically be a PCIe-related field, which is used to identify whether the device is currently in RC mode or EP mode. In this way, the device may determine the relevant device tree in RC mode or EP mode based on the root environment variable to activate the use of the device hardware resources so that the device may smoothly switch to RC mode or EP mode.
S30: and opening the corresponding device tree according to the RC mode or the EP mode.
Wherein a device tree is a data structure describing hardware resources. The method transmits the hardware resource to the kernel through the bootloader, so that the kernel and the hardware resource description are relatively independent. After the equipment tree is adopted, the equipment only needs to replace equipment tree files, dtb can realize the non-differential support of different mainboards, and kernel files do not need to be replaced. In the embodiment of the application, the device tree related to the RC mode and the EP mode is integrated, the corresponding device tree is determined to be started through the PCIe mode in the device starting stage, the full utilization of hardware resources can be realized in the same main board, and an implementation basis is provided for realizing the switching of different PCIe modes by the devices adopting the same main board. It can be appreciated that compared with the conventional manner of implementing an RC mode or an EP mode by a device, the present application can support the RC mode or the EP mode at the same time by the device, and can fully utilize the hardware resources of the device and apply the hardware resources to the operations in different modes.
S40: and acquiring the indication parameters based on the root environment variable, and loading a target drive according to the indication parameters in a kernel loading stage, wherein the target drive comprises an RC mode drive or an EP mode drive.
The indication parameter is used to indicate the PCIe mode adopted by the device, so that the device kernel (kernel) can know the PCIe mode to be adopted. It will be appreciated that the root environment variable of the device start-up phase is to enable a device tree related to RC mode or PCIe, and in the device kernel loading phase, the kernel needs to let the device enter a corresponding working mode according to the instruction parameter.
In an embodiment of the present application, the indication parameter may use the same field as the root environment variable for determining whether the device should currently use the RC mode or the EP mode. For example, the RC mode may be determined using the field pmiemde=rc and the EP mode may be determined using the field pmiemde=ep. In the kernel loading stage, uboot transmits the indication parameters, so that the kernel can load corresponding target drivers according to the indication parameters, and hardware resources can be smoothly switched to normal operation through the target drivers to interact with external connection equipment.
S50: and according to the device tree corresponding to the RC mode and the RC mode drive, or the device tree corresponding to the EP mode and the EP mode drive, finishing PCIe mode setting of the device.
In the embodiment of the application, different PCIe modes need the device tree and the drive corresponding to the modes, so that hardware resources related to the PCIe modes are applied to the devices of the same main board, and the devices can smoothly finish the work in the RC mode or the EP mode according to the drive corresponding to the modes. It will be appreciated that the network location and functionality of the device in RC mode, also known as master mode, may be different from that of the device in EP mode, which may be used to connect to an external expansion device, also known as slave mode, may be connected to a host instead of a USB (Universal Serial Bus ) interface. In different modes, the device will set the relevant routing and forwarding rules depending on the network application and division of work.
In the embodiment of the application, a root environment variable is read according to a device starting instruction, and PCIe is determined to be in an RC mode or an EP mode according to the root environment variable, so that the mode adopted by the device for starting at the time is determined when the device is started; then starting a corresponding equipment tree according to the RC mode or the EP mode to realize corresponding hardware resource support under different modes; and then acquiring an indication parameter based on a root environment variable, loading RC mode driving or EP mode according to the indication parameter in a kernel loading stage, finishing driving support for switching different modes in the kernel loading stage, and finally finishing PCIe mode setting of the device according to a device tree corresponding to the RC mode and the RC mode driving or a device tree corresponding to the EP mode and the EP mode driving, wherein when the device needs to be switched between the RC mode and the EP mode, the corresponding hardware resource support and the driving support can be quickly found, so that the device in the communication module can be accurately switched to the RC mode or the EP mode after being started. The embodiment of the application can integrate the RC mode and the EP mode in the communication module equipment, and can effectively reduce the problem of overhigh production cost of the communication module.
Further, before step S10, i.e. before reading the root environment variable according to the device start-up instruction, the method further comprises the steps of:
s111: and acquiring the equipment tree corresponding to the RC mode and the equipment tree corresponding to the EP mode.
In an embodiment, in order to realize switching between the RC mode and the EP mode, the device tree corresponding to the mode is extracted and obtained, so that under the same device, a technical basis is provided for realizing switching between the RC mode and the EP mode on the same device according to hardware resources required by the device tree mobilizing mode.
S112: RC mode driving and EP mode driving are acquired.
Wherein the driver is a special program added to the operating system, which contains information about the hardware device. This information enables the device to communicate with an externally connected device. The driver is a configuration file written by a hardware manufacturer according to an operating system, and the driver is provided, so that the hardware in the device can smoothly and accurately communicate with other devices in the network module, and the function of the hardware in different PCIe modes is completed. In an embodiment, the device should acquire an optional RC mode driver or EP mode driver in the kernel loading stage, and the present application may set the RC mode driver and the EP mode driver in advance in the same device to implement switching of different PCIe modes.
S113: and placing the device tree corresponding to the RC mode and the RC mode driver in the same software version, wherein after the device is started, the PCIe mode setting of the device is completed under the software version.
It will be appreciated that because of the gap in hardware circuit organization, the prior art generally requires burning both the RC mode software version and the EP mode software version, and that only one PCIe mode can be implemented on each device. In the embodiment of the application, the device tree and the RC mode driver corresponding to the RC mode are placed in the same software version, and after the device is started, the device tree and the driver can be selected by utilizing the indication parameters of the root environment and the kernel stage, so that the switching of the RC mode and the EP mode can be realized by the same device.
In steps S111-S113, through integrating device trees and drivers of different PCIe modes in the same software version, a technical basis for realizing switching between RC mode and EP mode on the same device is provided.
Further, in step S10, i.e. in reading the root environment variable according to the device start-up instruction, the method further comprises:
s121: and acquiring an AT command, wherein the AT command is sent by the external control equipment.
Among them, an AT (attention) instruction is an instruction applied to connection and communication between a device and a PC (personal computer) application. Specifically, an external control device (such as a computer used by a user) may send an AT command to the device by connecting to the (network module) device.
S122: and setting a root environment variable of the device according to the AT instruction, wherein the root environment variable comprises initial setting parameters for judging the PCIe mode of the device.
The external control device can input an initial setting parameter to the device through the AT command, wherein the initial setting parameter can be specifically expressed in a field mode, and the device can determine a PCIe mode adopted by the device required by the AT command in a network through the field. It will be appreciated that when a user needs to switch a device from one PCIe mode to another PCIe mode, the root environment variable of the device may be reset by the AT instruction so that the device switches to another PCIe mode after reading the environment variable.
S123: and reading the root environment variable according to the equipment starting instruction, and acquiring the initial setting parameters.
It will be appreciated that, when the device needs to perform mode switching, the device can restart the device and call the hardware resources required in the device according to the changed initial setting parameters, so that the same device can perform PCIe mode switching without any obstacle.
In steps S121-S123, the user may change the root environment variable by an AT command, so that the device determines to use the RC mode or the EP mode according to the root environment variable after being started, and invokes the corresponding hardware resource and driver.
Further, in step S30, that is, opening a corresponding device tree according to the RC mode or the EP mode, the method specifically includes the following steps:
and according to the initial setting parameters, determining that the equipment is in an RC mode or an EP mode, and starting a corresponding equipment tree.
In an embodiment, the initial setting parameter may be a value or a field representing a root environment variable, and by identifying the initial setting parameter, the device may determine a PCIe mode adopted by the device, so as to accurately obtain a device tree corresponding to the mode, so that hardware resources in the device may be accurately applied to different modes.
Further, in step S40, that is, obtaining the instruction parameters based on the root environment variable, in the kernel loading stage, loading the target drive according to the instruction parameters, specifically includes the following steps:
s41: and transmitting an indication parameter through Bootarg according to the root environment variable, wherein the indication parameter is used for indicating a PCIe mode adopted by the equipment.
In one embodiment, uboot is used to boot a loader, and its associated root environment variable may specifically employ Bootarg to implement the transfer of an indication parameter to transfer the indication parameter into the kernel. Wherein the value or field of the indication parameter may be the same as the initial setting parameter.
S42: in the kernel loading stage, the kernel invokes the instruction parameters transmitted by Bootarg through the installation function, and loads the target drive according to the instruction parameters.
The installation function may specifically refer to a_setup function adopted by the kernel. In an embodiment, the kernel fetches the hint parameters through the installation function callback, so that the root environment variable related to uboot can be transferred to the kernel in the kernel loading stage, and the kernel can smoothly and accurately load the target driver corresponding to the PCIe mode.
In the steps S41-S42, root environment variables are transferred to the kernel through Bootarg and an installation function, so that the kernel can realize information synchronization with uboot, and therefore correct target drive is loaded, and the same equipment can realize switching of different PCIe modes.
Further, in step S50, namely, the PCIe mode setting of the device is completed according to the device tree corresponding to the RC mode and the RC mode driving, or the device tree corresponding to the EP mode and the EP mode driving, specifically including the following steps:
s51: after the device starts a device tree corresponding to the RC mode and loads RC mode driving, determining a first network application rule according to parameters in the RC mode and Bootarg, and finishing RC mode setting of the device according to the first network application rule.
It can be understood that the RC mode is used as a master mode, and can be connected with an external extension device (PHY/LAN/Wi-Fi), so that the first network application rule can be determined according to actual network requirements, such as slave parameters, set in Bootarg, and division of work, so that the device adopting the RC mode can realize the function of being used as the master mode in the network module.
S52: and after the equipment starts the equipment tree corresponding to the EP mode and loads the EP mode drive, determining a second network application rule according to the parameters in the EP mode and Bootarg, and finishing the EP mode setting of the equipment according to the second network application rule.
Similar to the explanation of S51, a detailed description is omitted here.
In steps S51-S52, the device may automatically connect devices in the network according to the determined mode and parameters in Bootarg, and implement the role of its mode in the network module. Therefore, when the equipment is switched according to the requirements, the equipment can flexibly interact with the equipment in the network module by adopting different PCIe modes, and the configurability of the equipment and the network is improved.
Further, the method comprises the following steps:
in the production test stage, the PCIe mode test of the device is completed by adopting the RC mode.
It will be appreciated that only one PCIe mode of device is available in the prior art, requiring separate design of PCIe RC and EP test circuits and fixtures during the production test phase, which adds to the cost of production.
In the embodiment of the application, as the equipment can be switched to different modes without barriers, the hardware in the equipment can be used in common in different modes, and in fact, only the hardware performance of the equipment is required to be tested in the test stage. The application can only adopt RC mode to complete PCIe mode test of the equipment, or only adopts EP mode to complete PCIe mode test of the equipment, thus remarkably reducing production cost.
Further, the method comprises the following steps:
when PCIe mode conversion, the root environment variable and the indication parameter are changed by acquiring the AT instruction to switch the device from the RC mode to the EP mode or to switch the device from the EP mode to the RC mode.
In an embodiment, the indication parameter is transmitted by a root environment variable, and the indication parameter is changed along with the change of the AT instruction, so that the device kernel can find a correct drive corresponding to the PCIe mode, and the device can simply and accurately complete mode switching according to the AT instruction.
FIG. 2 is a flow chart of another PCIe RC and EP mode switching method in an embodiment of the present application. As shown in fig. 2, after the device is started, a root environment variable is read, then a PCIe mode is determined according to the root environment variable, an RC-related device tree is enabled or an RC-related device tree is enabled, then a prompt parameter is transmitted through Bootarg, an RC driver or an RC driver is loaded by using an installation parameter, a corresponding device node is regenerated, and finally a network upper layer can read routing and forwarding rules under different modes of Bootarg parameter devices.
FIG. 3 is a flowchart of another PCIe RC and EP mode switching method in an embodiment of the present application. As shown in fig. 3, after the device is started, the device sets and stores PCIe root environment variables through an AT instruction processing program, where an AT instruction may be sent through an external control device, and control of an RC mode or an EP mode is implemented.
In the embodiment of the application, a root environment variable is read according to a device starting instruction, and PCIe is determined to be in an RC mode or an EP mode according to the root environment variable, so that the mode adopted by the device for starting at the time is determined when the device is started; then starting a corresponding equipment tree according to the RC mode or the EP mode to realize corresponding hardware resource support under different modes; and then acquiring an indication parameter based on a root environment variable, loading RC mode driving or EP mode according to the indication parameter in a kernel loading stage to finish driving support for switching different modes in the kernel loading stage, and finally finishing PCIe mode setting of the equipment according to equipment tree corresponding to the RC mode and RC mode driving or equipment tree corresponding to the EP mode and EP mode driving, wherein when the equipment needs to be switched between the RC mode and the EP mode, the corresponding hardware resource support and driving support can be quickly found, so that the equipment in the communication module can be accurately switched to the RC mode or the EP mode after being started. The embodiment of the application can integrate the RC mode and the EP mode in the communication module equipment, and can effectively reduce the problem of overhigh production cost of the communication module.
Furthermore, the application also provides a technical foundation for realizing switching between the RC mode and the EP mode on the same device by integrating the device tree and the driver of different PCIe modes in the same software version.
Furthermore, the application can also change the root environment variable through the AT instruction, so that the device can determine to adopt the RC mode or the EP mode according to the root environment variable after being started, and call corresponding hardware resources and drive the same device to realize mode switching.
Furthermore, the root environment variable is transferred to the kernel through the Bootarg and the installation function, so that the kernel can realize information synchronization with uboot, and accordingly the strive target drive is loaded, and it becomes possible for the same device to realize different PCIe modes.
Furthermore, the application can also automatically connect the devices in the network according to the determined mode and the parameters in Bootarg, and the like, and realize the function of the mode in the network module. Therefore, when the equipment is switched according to the requirements, the equipment can flexibly interact with the equipment in the network module by adopting different PCIe modes, and the configurability of the equipment and the network is improved.
Furthermore, the application can also complete the PCIe mode test of the device by adopting the RC mode only or complete the PCIe mode test of the device by adopting the EP mode only, thus the production cost can be obviously reduced.
It should be understood that the sequence number of each step in the foregoing embodiment does not mean that the execution sequence of each process should be determined by the function and the internal logic, and should not limit the implementation process of the embodiment of the present application.
FIG. 4 is a schematic block diagram of a PCIe RC and EP mode switching device in an embodiment of the present application. As shown in fig. 4, the PCIe RC and EP mode switching device includes a reading module 10, a judging module 20, a device tree opening module, a drive loading module 40, and a mode device module 50.
The reading module is used for reading the root environment variable according to the equipment starting instruction;
the judging module is used for judging a PCIe mode according to the root environment variable, wherein the PCIe mode comprises an RC mode or an EP mode;
the device tree starting module is used for starting the corresponding device tree according to the RC mode or the EP mode;
the drive loading module is used for acquiring the indication parameters based on the root environment variable and loading a target drive according to the indication parameters in a kernel loading stage, wherein the target drive comprises an RC mode drive or an EP mode drive;
and the mode setting module is used for driving according to the equipment tree corresponding to the RC mode and the RC mode, or finishing PCIe mode setting of the equipment according to the equipment tree corresponding to the EP mode and the EP mode.
Further, the device is also specifically used for:
acquiring a device tree corresponding to an RC mode and a device tree corresponding to an EP mode;
acquiring RC mode driving and EP mode driving;
and placing the device tree corresponding to the RC mode and the RC mode driver in the same software version, wherein after the device is started, the PCIe mode setting of the device is completed under the software version.
Further, the reading module is specifically configured to:
acquiring an AT instruction, wherein the AT instruction is sent by external control equipment;
setting a root environment variable of the device according to the AT instruction, wherein the root environment variable comprises initial setting parameters for judging a PCIe mode of the device;
and reading the root environment variable according to the equipment starting instruction, and acquiring the initial setting parameters.
Further, the device tree opening module is specifically further configured to:
and according to the initial setting parameters, determining that the equipment is in an RC mode or an EP mode, and starting a corresponding equipment tree.
Further, the drive loading module is specifically configured to:
transmitting an indication parameter through Bootarg according to a root environment variable, wherein the indication parameter is used for indicating a PCIe mode adopted by the equipment;
in the kernel loading stage, the kernel invokes the instruction parameters transmitted by Bootarg through the installation function, and loads the target drive according to the instruction parameters.
Further, the mode setting module is specifically configured to:
after equipment starts an equipment tree corresponding to an RC mode and loads RC mode driving, determining a first network application rule according to parameters in the RC mode and Bootarg, and finishing RC mode setting of the equipment according to the first network application rule;
and after the equipment starts the equipment tree corresponding to the EP mode and loads the EP mode drive, determining a second network application rule according to the parameters in the EP mode and Bootarg, and finishing the EP mode setting of the equipment according to the second network application rule.
Further, the device is also specifically used for:
in the production test stage, the PCIe mode test of the device is completed by adopting the RC mode.
Further, the device is also specifically used for:
when PCIe mode conversion, the root environment variable and the indication parameter are changed by acquiring the AT instruction to switch the device from the RC mode to the EP mode or to switch the device from the EP mode to the RC mode.
In the embodiment of the application, a root environment variable is read according to a device starting instruction, and PCIe is determined to be in an RC mode or an EP mode according to the root environment variable, so that the mode adopted by the device for starting at the time is determined when the device is started; then starting a corresponding equipment tree according to the RC mode or the EP mode to realize corresponding hardware resource support under different modes; and then acquiring an indication parameter based on a root environment variable, loading RC mode driving or EP mode according to the indication parameter in a kernel loading stage to finish driving support for switching different modes in the kernel loading stage, and finally finishing PCIe mode setting of the equipment according to equipment tree corresponding to the RC mode and RC mode driving or equipment tree corresponding to the EP mode and EP mode driving, wherein when the equipment needs to be switched between the RC mode and the EP mode, the corresponding hardware resource support and driving support can be quickly found, so that the equipment in the communication module can be accurately switched to the RC mode or the EP mode after being started. The embodiment of the application can integrate the RC mode and the EP mode in the communication module equipment, and can effectively reduce the problem of overhigh production cost of the communication module.
Fig. 5 is a schematic diagram of a terminal device in an embodiment of the present application.
As shown in fig. 5, terminal device 110 includes a processor 111, a memory 112, and computer readable instructions 113 stored in memory 112 and executable on processor 111. The processor 111, when executing the computer readable instructions 113, implements the steps of the RC and EP mode switching method of PCIe.
Illustratively, the computer readable instructions 113 may be partitioned into one or more modules/units, which are stored in the memory 112 and executed by the processor 111 to complete the present application. One or more of the modules/units may be a series of computer readable instructions capable of performing a particular function, the instruction describing the execution of the computer readable instructions 113 in the terminal device 110.
The terminal device 110 may be a computing device such as a desktop computer, a notebook computer, a palm computer, and a cloud server. Terminal devices may include, but are not limited to, a processor 111, a memory 112. It will be appreciated by those skilled in the art that fig. 5 is merely an example of terminal device 110 and is not meant to be limiting as terminal device 110, and may include more or fewer components than shown, or may combine certain components, or different components, e.g., a terminal device may also include an input-output device, a network access device, a bus, etc.
The processor 111 may be a central processing unit (Central Processing Unit, CPU), but may also be other general purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), field programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
Memory 112 may be an internal storage unit of terminal device 110, such as a hard disk or memory of terminal device 110. The memory 112 may also be an external storage device of the terminal device 110, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card) or the like, which are provided on the terminal device 110. Further, the memory 112 may also include both internal storage units and external storage devices of the terminal device 110. Memory 112 is used to store computer readable instructions as well as other programs and data required by the terminal device. The memory 112 may also be used to temporarily store data that has been output or is to be output.
The embodiment of the application can acquire and process the related data based on the artificial intelligence technology. Among these, artificial intelligence (Artificial Intelligence, AI) is the theory, method, technique and application system that uses a digital computer or a digital computer-controlled machine to simulate, extend and extend human intelligence, sense the environment, acquire knowledge and use knowledge to obtain optimal results.
Artificial intelligence infrastructure technologies generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technologies, operation/interaction systems, mechatronics, and the like. The artificial intelligence software technology mainly comprises a computer vision technology, a robot technology, a biological recognition technology, a voice processing technology, a natural language processing technology, machine learning/deep learning and other directions.
In the embodiment of the application, the server can be an independent server, or can be a cloud server for providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (ContentDelivery Network, CDNs), basic cloud computing services such as big data and artificial intelligent platforms, and the like.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-described division of the functional units and modules is illustrated, and in practical application, the above-described functional distribution may be performed by different functional units and modules according to needs, i.e. the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-described functions.
In addition, each functional unit in the embodiments of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The integrated modules/units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the present application may also be implemented by implementing all or part of the processes in the methods of the embodiments described above, by instructing the associated hardware by means of computer readable instructions, which may be stored in a computer readable storage medium, the computer readable instructions, when executed by a processor, implementing the steps of the respective method embodiments described above. Wherein the computer readable instructions comprise computer readable instruction code which may be in the form of source code, object code, executable files, or in some intermediate form, etc. The computer readable medium may include: any entity or device capable of carrying the computer readable instruction code, a recording medium, a USB flash disk, a removable hard disk, a magnetic disk, an optical disk, a computer Memory, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), an electrical carrier wave signal, a telecommunications signal, a software distribution medium, and so forth. It should be noted that the computer readable medium may include content that is subject to appropriate increases and decreases as required by jurisdictions in which such content is subject to legislation and patent practice, such as in certain jurisdictions in which such content is not included as electrical carrier signals and telecommunication signals.
The present application also provides a computer readable storage medium storing computer readable instructions that, when executed by a processor, implement the RC and EP mode switching method of the above embodiment PCIe.
The above embodiments are only for illustrating the technical solution of the present application, and are not limiting; although the application has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present application, and are intended to be included in the scope of the present application.

Claims (9)

1. An RC and EP mode switching method for PCIe, comprising:
acquiring a device tree corresponding to the RC mode and a device tree corresponding to the EP mode;
acquiring RC mode driving and EP mode driving;
placing the equipment tree corresponding to the RC mode and the RC mode driver in the same software version, wherein after equipment is started, PCIe mode setting of the equipment is completed under the software version;
Reading a root environment variable according to a device starting instruction;
judging a PCIe mode according to the root environment variable, wherein the PCIe mode comprises an RC mode or an EP mode;
starting a corresponding equipment tree according to the RC mode or the EP mode;
acquiring an indication parameter based on the root environment variable, and loading a target drive according to the indication parameter in a kernel loading stage, wherein the target drive comprises an RC mode drive or an EP mode drive;
and driving according to the equipment tree corresponding to the RC mode and the RC mode, or finishing the PCIe mode setting of the equipment according to the equipment tree corresponding to the EP mode and the EP mode.
2. The method of claim 1, wherein the reading the root environment variable according to the device boot instruction comprises:
acquiring an AT instruction, wherein the AT instruction is sent by external control equipment;
setting the root environment variable of the equipment according to the AT instruction, wherein the root environment variable comprises initial setting parameters for judging the PCIe mode of the equipment;
reading the root environment variable according to a device starting instruction, and acquiring the initial setting parameters;
the opening the corresponding device tree according to the RC mode or the EP mode comprises the following steps:
And according to the initial setting parameters, determining that the equipment is in the RC mode or the EP mode, and starting the corresponding equipment tree.
3. The method according to claim 1 or 2, wherein the obtaining an indication parameter based on the root environment variable, loading a target driver according to the indication parameter in a kernel loading phase, comprises:
transmitting an indication parameter through Bootarg according to the root environment variable, wherein the indication parameter is used for indicating the PCIe mode adopted by the equipment;
and in the kernel loading stage, the kernel invokes the indication parameters transmitted by Bootarg through an installation function, and loads the target drive according to the indication parameters.
4. The method according to claim 1 or 2, wherein the driving according to the device tree and the RC mode corresponding to the RC mode or the device tree and the EP mode corresponding to the EP mode completes the PCIe mode setting of a device, includes:
after the equipment starts the equipment tree corresponding to the RC mode and loads the RC mode drive, determining a first network application rule according to parameters in the RC mode and Bootarg, and completing the RC mode setting of the equipment according to the first network application rule;
And after the equipment starts the equipment tree corresponding to the EP mode and loads the EP mode driver, determining a second network application rule according to the parameters in the EP mode and Bootarg, and finishing the EP mode setting of the equipment according to the second network application rule.
5. The method according to claim 1, wherein the method further comprises:
and in a production test stage, completing the PCIe mode test of the device by adopting the RC mode.
6. The method according to claim 1, wherein the method further comprises:
when the PCIe mode is converted, the root environment variable and the indication parameter are changed by acquiring an AT instruction to switch the device from the RC mode to the EP mode or switch the device from the EP mode to the RC mode.
7. An RC and EP mode switching device for PCIe, comprising:
acquiring a device tree corresponding to the RC mode and a device tree corresponding to the EP mode;
acquiring RC mode driving and EP mode driving;
placing the equipment tree corresponding to the RC mode and the RC mode driver in the same software version, wherein after equipment is started, PCIe mode setting of the equipment is completed under the software version;
The reading module is used for reading the root environment variable according to the equipment starting instruction;
the judging module is used for judging a PCIe mode according to the root environment variable, wherein the PCIe mode comprises an RC mode or an EP mode;
the equipment tree opening module is used for opening the corresponding equipment tree according to the RC mode or the EP mode;
the drive loading module is used for acquiring indication parameters based on the root environment variable, and loading a target drive according to the indication parameters in a kernel loading stage, wherein the target drive comprises RC mode drive or EP mode drive;
and the mode setting module is used for driving according to the equipment tree corresponding to the RC mode and the RC mode, or finishing the PCIe mode setting of the equipment according to the equipment tree corresponding to the EP mode and the EP mode.
8. A terminal device comprising a memory, a processor, and computer readable instructions stored in the memory and executable on the processor, wherein the processor, when executing the computer readable instructions, performs the steps of the RC and EP mode switching method for PCIe as set forth in any one of claims 1-6.
9. A computer readable storage medium storing computer readable instructions which, when executed by a processor, implement the steps of the RC and EP mode switching method for PCIe of any one of claims 1-6.
CN202210428764.5A 2022-04-22 2022-04-22 PCIe RC and EP mode switching method, device, equipment and medium Active CN114826907B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210428764.5A CN114826907B (en) 2022-04-22 2022-04-22 PCIe RC and EP mode switching method, device, equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210428764.5A CN114826907B (en) 2022-04-22 2022-04-22 PCIe RC and EP mode switching method, device, equipment and medium

Publications (2)

Publication Number Publication Date
CN114826907A CN114826907A (en) 2022-07-29
CN114826907B true CN114826907B (en) 2023-08-11

Family

ID=82506121

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210428764.5A Active CN114826907B (en) 2022-04-22 2022-04-22 PCIe RC and EP mode switching method, device, equipment and medium

Country Status (1)

Country Link
CN (1) CN114826907B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2014000271A1 (en) * 2012-06-29 2014-01-03 华为技术有限公司 Pcie switching system, apparatus and switching method
CN107077521A (en) * 2014-12-20 2017-08-18 英特尔公司 On-chip system configures metadata
CN112416834A (en) * 2020-11-30 2021-02-26 上海壁仞智能科技有限公司 Interconnection method between devices compatible with PCIe structure and related devices
CN114328329A (en) * 2021-11-09 2022-04-12 深圳市广和通无线股份有限公司 Communication module design method and device compatible with master and slave devices

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2014000271A1 (en) * 2012-06-29 2014-01-03 华为技术有限公司 Pcie switching system, apparatus and switching method
CN107077521A (en) * 2014-12-20 2017-08-18 英特尔公司 On-chip system configures metadata
CN112416834A (en) * 2020-11-30 2021-02-26 上海壁仞智能科技有限公司 Interconnection method between devices compatible with PCIe structure and related devices
CN114328329A (en) * 2021-11-09 2022-04-12 深圳市广和通无线股份有限公司 Communication module design method and device compatible with master and slave devices

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
基于PCI-E总线的气象传真接收机设计与实现;刘鉴德;中国优秀硕士学位论文全文数据库 工程科技Ⅱ辑;全文 *

Also Published As

Publication number Publication date
CN114826907A (en) 2022-07-29

Similar Documents

Publication Publication Date Title
CN112996020B (en) Bluetooth-based automatic test method and device and Bluetooth test terminal
CN109783340B (en) SoC test code programming method, IP test method and device
US10140231B2 (en) Flexible port configuration based on interface coupling
WO2021136200A1 (en) Bootloader loading method, storage medium, and embedded terminal
CN111901164A (en) Adaptive control method, device, equipment and system for OCP NIC network card
CN116132009A (en) Clock switching device, server and clock switching method
CN108108314B (en) Exchanger system
CN114826907B (en) PCIe RC and EP mode switching method, device, equipment and medium
CN115134427B (en) Communication protocol coordination method, device, computer equipment and storage medium
CN114579499B (en) Control method, device, equipment and storage medium of processor communication interface
CN113821265B (en) Operating system control method and device, computer mainboard and readable storage medium
CN107885674B (en) Bluetooth device simulator, working method thereof and Bluetooth device operating system
CN112069102B (en) GPIO controller configuration method and system
CN112069113B (en) I2C device configuration method and system
WO2021057648A1 (en) Esim card, method for processing and setting card application, terminal and platform device
CN113064833A (en) Single chip microcomputer simulation method, system, device, equipment and storage medium
CN108804144B (en) Control method/system for starting operating system, storage medium and electronic equipment
CN113472611A (en) Method and device for acquiring WiFi signal strength and readable storage medium
CN112433971A (en) Structure, method and medium for realizing processor self-adaptive SATA and NVME M.2
CN112988638B (en) Keyboard interface multiplexing method and electronic equipment
CN113535213B (en) Firmware updating method and system for programmable logic device
CN112015452B (en) Firmware upgrading method and device for gate system and gate system
CN115599191B (en) Power-on method and power-on device of intelligent network card
CN219590811U (en) Data burning device
CN116243994B (en) Driving loading method of storage device, operating system starting 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