CN118093481A - Method and device for realizing computer interface expansion switching - Google Patents
Method and device for realizing computer interface expansion switching Download PDFInfo
- Publication number
- CN118093481A CN118093481A CN202410459672.2A CN202410459672A CN118093481A CN 118093481 A CN118093481 A CN 118093481A CN 202410459672 A CN202410459672 A CN 202410459672A CN 118093481 A CN118093481 A CN 118093481A
- Authority
- CN
- China
- Prior art keywords
- working
- computer interface
- mode
- host
- function
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 43
- 230000006870 function Effects 0.000 claims description 153
- 238000004088 simulation Methods 0.000 claims description 28
- 238000011144 upstream manufacturing Methods 0.000 description 28
- 238000005516 engineering process Methods 0.000 description 8
- 238000010586 diagram Methods 0.000 description 7
- 230000008569 process Effects 0.000 description 7
- 230000004048 modification Effects 0.000 description 6
- 238000012986 modification Methods 0.000 description 6
- 230000004044 response Effects 0.000 description 5
- 238000012545 processing Methods 0.000 description 2
- 238000004422 calculation algorithm Methods 0.000 description 1
- 238000004364 calculation method Methods 0.000 description 1
- 230000008859 change Effects 0.000 description 1
- 238000004891 communication Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000013507 mapping Methods 0.000 description 1
- 230000008520 organization Effects 0.000 description 1
- 230000002093 peripheral effect Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 230000009466 transformation Effects 0.000 description 1
- 238000000844 transformation Methods 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F13/00—Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
- G06F13/38—Information transfer, e.g. on bus
- G06F13/40—Bus structure
- G06F13/4004—Coupling between buses
- G06F13/4022—Coupling between buses using switching circuits, e.g. switching matrix, connection or expansion network
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F13/00—Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
- G06F13/38—Information transfer, e.g. on bus
- G06F13/382—Information transfer, e.g. on bus using universal interface adapter
- G06F13/387—Information transfer, e.g. on bus using universal interface adapter for adaptation of different data processing systems to different peripheral devices, e.g. protocol converters for incompatible systems, open system
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Mathematical Physics (AREA)
- Computer Hardware Design (AREA)
- Information Transfer Systems (AREA)
Abstract
The invention provides a method and a device for realizing the expansion switching of a computer interface, wherein the method comprises the steps that a host acquires the working mode information of the computer interface device, and whether the working mode of the computer interface device needs to be replaced or not is determined according to the working mode information of the computer interface device; after the host switches the working mode of the computer interface device from a single device mode to a virtual switch mode, presenting a virtual switch to the host, wherein the virtual switch comprises an uplink port and more than two downlink ports, and also presents more than two first working devices, and each presented first working device corresponds to one downlink port; after the host switches the operation mode of the computer interface device from the virtual switch mode to the single device mode, only one second operation device is presented to the host. The device is used for realizing the method. The invention can enable the user to flexibly switch the working mode of the computer interface device.
Description
Technical Field
The invention relates to the technical field of computer interface equipment, in particular to a method for realizing computer interface expansion switching and a device for realizing the method.
Background
With the development of computer technology, more and more computer devices apply computer interface expansion technology to expand computer interfaces. Among them, PCIE and CXL are two common computer interface expansion techniques.
PCIE, namely PCI-Express (peripheral component interconnect express), is a standard interface technology proposed by PCI-SIG organization for connecting internal components of a computer, and the architecture of the PCIE comprises PCIE devices of the types of root component RC (root complex), switch (switch), endpoint device (ep) and the like. The switch is used for expanding the PCIE interface, so that the host or the root component is connected with more endpoint devices.
CXL (Compute Express Link) is a novel high-speed interconnection technology, which adopts PCIE physical layer specification and introduces CXL.io, CXL.cache and CXL.mem protocols to meet the high-bandwidth and low-delay communication requirements between the core accelerators of modern computer processors. Its architecture also consists of CXL devices of the type root component RC (root complex), switch, and endpoint device (SLD or MLD). As with PCIE technology, switches are also used to extend the CXL interface, enabling hosts or root components to connect to more endpoint devices.
For example, the invention patent application with publication number CN116521596a discloses a method and a device for implementing PCIE SWITCH simulator based on Qemu virtual environment, the method can implement virtual switch, and the expansion of computer interface is implemented through virtual switch. However, this solution only enables virtualization of the switch and is not capable of switching modes of operation, for example in some scenarios where a user wants a host to connect to only one endpoint device, while in other scenarios where a user wants a host to connect to multiple endpoint devices, the solution is not capable of flexible transformations for computer interface extensions in different scenarios.
Disclosure of Invention
A first object of the present invention is to provide a method for implementing computer interface expansion switching that is capable of flexibly switching operation modes.
A second object of the present invention is to provide an apparatus for implementing the method for implementing the extended switching of a computer interface.
In order to achieve the first object of the present invention, the method for implementing computer interface expansion switching provided by the present invention includes: the host acquires the working mode information of the computer interface device, and determines whether the working mode of the computer interface device needs to be replaced according to the working mode information of the computer interface device; after the host switches the working mode of the computer interface device from a single device mode to a virtual switch mode, presenting a virtual switch to the host, wherein the virtual switch comprises an uplink port and more than two downlink ports, and also presents more than two first working devices, each presented first working device corresponds to one downlink port, the uplink port, each downlink port and each first working device are configured with corresponding configuration spaces, and the uplink port, each downlink port and each first working device are allocated with corresponding base address register spaces; after the host switches the working mode of the computer interface device from the virtual switch mode to the single device mode, only one second working device is presented to the host, and the second working device is configured with a corresponding configuration space and is allocated with a corresponding base register space.
The above scheme shows that the computer interface device can work in a single device mode and a virtual switch mode, and can flexibly switch the working modes of the computer interface device, so that the working mode of the computer interface device is set to the single device mode when a host only needs to be connected with a single working device, and the computer interface device is set to the virtual switch mode when the host needs to be connected with a plurality of working devices. The computer interface device can be flexibly set into two different working modes, so that the computer interface device can adapt to the use requirements in different scenes.
In a preferred embodiment, the host switching the operation mode of the computer interface device from the single device mode to the virtual switch mode includes: the host computer modifies the data of the nonvolatile memory of the computer interface device, the host computer is restarted, and the configuration space and the base register space are initialized according to the updated working mode when the host computer is restarted; each first working device corresponds to at least one first function, each first working device has a unique device number, each first function of each first working device has a corresponding function number, and each first function of each first working device is identified by the device number and the function number.
Therefore, the switching of the working modes of the computer interface device can be realized by modifying the data of the nonvolatile memory of the computer interface device through the host, so that a user can conveniently send a simple command through the host to realize the switching of the working modes of the computer interface device, and the switching of the working modes of the computer interface device is very flexible.
Optionally, the host switching the operation mode of the computer interface device from the single device mode to the virtual switch mode includes: the host modifies data of the nonvolatile memory of the computer interface device; the base address register spaces of the functions of the uplink port, the base address register spaces of the functions of the downlink port, and the base address register spaces of the first functions of each first working device are each configured with a corresponding base address number.
It can be seen that the user can also modify the data of the nonvolatile memory of the computer interface device through the host computer to realize the switching of the working modes of the computer interface device, and can also flexibly realize the switching of the working modes of the computer interface device.
Further, each first working device corresponds to at least one first function, each first function of each first working device has a corresponding function number, and a device number, a function number, and a base address number are used to identify a specific base address register space of each first function of each first working device.
Therefore, by setting the function number of the first function of each first working device, the storage address corresponding to the function of the corresponding working device can be quickly found.
Further, the method further comprises initializing a configuration space of the computer interface device: and when the configuration request information sent by the host is received for the first time, reading the register ID, if so, judging whether the current working mode is a virtual switch mode, if so, initializing configuration spaces of the uplink port, the downlink port and the first working equipment, and deducing the corresponding uplink port, the downlink port, the first working equipment and the corresponding first function according to a target bus in the configuration request information and a topological structure to be presented.
Further, the method further comprises initializing a base register space of the computer interface device: the host acquires the physical address of mapping each first working device or the internal space supported by the first function to the host memory.
It can be seen that, during the initialization operation of the configuration space and the base register space, the initialization operation needs to be performed for each first working device, the configuration space corresponding to the first function, and the physical address, and when the virtual switch mode is subsequently switched, the initialization is performed after the host is restarted, and the configuration of the configuration space, the configuration of the physical address, and the like of the first working device are implemented by using the initialization result. And if the mode is switched to the single equipment mode, the host computer also executes initialization operation after restarting, and the configuration of the configuration space and the information of the base register space of the second working equipment can be obtained.
In order to achieve the second object, the present invention provides a computer interface device having an operation mode storage unit configured to store an operation mode of the computer interface device, where the operation mode includes a single device mode and a virtual switch mode; when the computer interface device is in a virtual switch mode, presenting a virtual switch to the host, wherein the virtual switch comprises an uplink port and more than two downlink ports, and further comprises more than two first working devices, each presented first working device corresponds to one downlink port, the uplink port, each downlink port and each first working device are configured with a corresponding configuration space, and the uplink port, each downlink port and each first working device are allocated with a corresponding base address register space; in the single device mode, only one second working device is presented to the host, the second working device being configured with a corresponding configuration space and with a corresponding base register space.
According to the scheme, the working mode storage unit of the computer interface device can store the current working mode, a user can modify the working mode according to the actual use requirement, and after the working mode is modified, the topology structure presented to the host is correspondingly changed, so that the working mode of the computer interface device is flexibly adjusted.
In a preferred embodiment, the computer interface device is further provided with a configuration space simulation unit; in the virtual exchanger mode, the configuration space simulation unit simulates the configuration space corresponding to each function of the uplink port, each downlink port and each first working device; the configuration space simulation unit simulates the configuration space corresponding to each second function of the second working equipment when the computer interface is in the single equipment mode.
The above scheme shows that the configuration space simulation unit stores the information of the corresponding configuration space of the computer interface device in the virtual switch mode and the single device mode, so that the configuration space simulation unit can adapt to the operation requirements of the computer interface device in two different modes.
Optionally, the computer interface device is further provided with a base address register space simulation unit; in the virtual switch mode, the base address register space simulation unit stores base address numbers of the base address register spaces of the functions of the uplink ports, base address numbers of the base address register spaces of the functions of the downlink ports, equipment numbers of the first working equipment, function numbers of the first functions of the first working equipment and base address numbers of the base address registers of the first functions; in the single device mode, the base address register space simulation unit stores the device number of the second working device, the function number of each second function of the second working device, and the base address number of each base address register of each second function.
Therefore, the base register space simulation unit also stores the device numbers and function numbers corresponding to the working devices and functions of the computer interface device in the virtual switch mode and the single device mode, so that the computer interface device can flexibly switch between the two working modes.
The configuration space simulation unit is used for storing the configuration space of the uplink port, the downlink port and the first working equipment in an isolated mode according to the equipment type; the uplink port, the downlink port and the base address register space of the first working device stored by the base address register space simulation unit are stored in an isolated mode according to the device type.
Drawings
FIG. 1 is a schematic diagram of an embodiment of an apparatus for implementing computer interface expansion switching of the present invention operating in a single device mode.
Fig. 2 is a schematic diagram of an embodiment of an apparatus for implementing computer interface expansion switching of the present invention operating in virtual switch mode.
Fig. 3 is a schematic diagram of data and operation of an embodiment of an apparatus for implementing computer interface extension switching.
Fig. 4 is a schematic diagram of a configuration space simulation of each device in a virtual switch mode according to an embodiment of the apparatus for implementing computer interface expansion switching.
Fig. 5 is a schematic diagram illustrating a configuration space simulation of an operating device in a single device mode according to an embodiment of the apparatus for implementing computer interface expansion switching.
Fig. 6 is a schematic diagram illustrating a spatial simulation of a base register of each device in a virtual switch mode according to an embodiment of the apparatus for implementing computer interface extended switching.
FIG. 7 is a schematic diagram illustrating a spatial simulation of the base register of each device in a single device mode according to an embodiment of the apparatus for implementing computer interface extension switching.
FIG. 8 is a flow chart of a method embodiment of the present invention for implementing computer interface expansion switching by configuring a space switching mode of operation.
FIG. 9 is a flow chart of a method embodiment of the present invention for implementing computer interface expansion switching by base register space switching modes of operation.
FIG. 10 is a flow chart of a method embodiment of the present invention for implementing a computer interface extension switch to present a different device after an operating mode switch.
FIG. 11 is a flow chart of a method embodiment of the present invention for implementing computer interface extension switching in different device configuration space initialization.
FIG. 12 is a flow chart of a method embodiment of the present invention for implementing computer interface extended handoff in locating the configuration space of devices.
The invention is further described below with reference to the drawings and examples.
Detailed Description
The method for realizing the expansion switching of the computer interface is applied to the computer interface equipment, and the computer interface equipment can work in a virtual exchanger mode and also can work in a single equipment mode.
An embodiment of a device for realizing computer interface expansion switching:
The present embodiment is applied to a computer interface device, which has two operation modes, i.e., a single device mode and a virtual switch mode, respectively, referring to fig. 1, when the computer interface device 20 operates in the single device mode, only one operation device is presented to the host 10, e.g., only the second operation device 15 is presented. If operating in virtual switch mode, see fig. 2, the computer interface device 20 presents a virtual switch to the host 10, the virtual switch comprising an upstream port 25 and further comprising a plurality of downstream ports, e.g. comprising downstream ports 21, 22, 23, 24, each connected to a working device, e.g. downstream port 21 connected to a first working device 31, downstream port 22 connected to a first working device 32, downstream port 23 connected to a first working device 33, downstream port 24 connected to a first working device 34.
The computer interface device 20 can flexibly switch between two modes of operation, and therefore, expansion of the interface device can be achieved when the computer interface device 20 is operated in a virtual switch mode. Preferably, the expansion technology of the computer interface device of the embodiment may apply PCIE technology or CXL technology.
Referring to fig. 3, a memory is provided in the computer interface device 20, and the memory includes a nonvolatile memory 41 and a volatile memory 42, and data used by the computer interface device 20 is stored in the nonvolatile memory 41 and the volatile memory 42, respectively. For example, an operation mode storage unit 45 is provided in the nonvolatile memory 41 for storing an operation mode of the computer interface device 20, i.e., recording whether the computer interface device 20 is currently operating in the single device mode or the virtual switch mode. Since the information of the operation mode is stored in the nonvolatile memory 41, when the computer interface device 20 is powered off and then started again, the last operation mode is recorded and the operation is continued in the last operation mode.
A configuration space simulation unit 46 and a base register simulation unit 47 are disposed in the volatile memory 42, and the configuration space simulation unit 46 is configured to store configuration parameter information of the configuration space of the computer interface device 20 in the single device mode and the virtual switch mode. For example, in the virtual switch mode, the computer interface device 20 needs to present a virtual switch to the host 10, which includes an upstream port and a plurality of downstream ports, and for this purpose, the configuration space emulation unit 46 needs to store parameters of the configuration spaces of the upstream port, the downstream port, and the plurality of first working devices.
Referring to fig. 4, it is assumed that the virtual switch supports N downstream ports and N first working devices, where N is less than or equal to 32, and the upstream ports support X functions, X is less than or equal to 8, each downstream port supports Y functions, Y is less than or equal to 8, and each first working device supports M functions, where M is less than or equal to 8. In addition, the number of functions supported by each downlink port is not necessarily equal, and the functions supported by each first working device are not necessarily equal. In this embodiment, N downstream ports and N first working devices are organized according to an array, and each function of an upstream port, each downstream port, and each first working device has a corresponding configuration space.
Specifically, each Function of the uplink port has its own Function number, so each Function of the uplink port may be identified by the Function number, and a certain Function of the uplink port may be identified as an uplink port configuration space [ Function ], where [ Function ] is a Function number in the TLP configuration packet.
Accordingly, each downstream port may be identified by a "target Device" field in the packet, and each Function of each downstream port also has its own Function number, so if the host needs to access a certain Function of a certain downstream port, it may be accessed by a downstream port configuration space [ Device ] [ Function ], where [ Device ] is the Device number of the "target Device" field in the TLP configuration packet.
In this embodiment, a unique device number is set for each first working device, and since the array subscript in the configuration space simulation unit is from 0 to the number of devices, for example, the number of downlink ports is 4, and corresponds to 4 first working devices, the array access subscript ranges from 0 to 3. However, in the TLP configuration packet, the device numbers in the BDF information (bus, device, function information) of all the first working devices are set to 0 during actual access, so when determining what device the host accesses currently, the following formula may be used to calculate: target bus number in TLP configuration packet-downstream port bus number-1.
In addition, a corresponding Function number is also set for one Function of each working device, so that the first Function of each first working device can be identified by using the device number and the Function number, the host 10 can access the configuration space of a certain Function of a specific first working device by combining the device number and the Function number, and the configuration space of a certain Function of the first working device can be identified as a first working device configuration space [ target Bus-dsp.bus-1] [ Function ], where the target Bus is a target Bus number in the TLP configuration packet, and the dsp.bus is a downlink port Bus number.
For each function of the upstream port, each downstream port, or the first working device, a configuration space thereof may store parameters such as a type header (TYPE HEADER), basic Capability (Basic Capability), and extended Capability (Extended Capability). And, the configuration space of the upstream port, the downstream port and the first working device needs to be stored separately according to the type of the device, and is stored in a manner of being simulated in the space allocated from the volatile storage area.
If the computer interface device 20 is operating in the single device mode, the computer interface device 20 presents only one second operating device to the host 10, e.g., the second operating device has a device number N-1, at which point the configuration space emulation unit 46 stores a data structure as shown in FIG. 5. In this embodiment, the second working device may support M functions, and preferably M is less than or equal to 8. And, for each function, using a unique function number identification, the host 10 accesses a configuration space of a certain function by using the function number as an array subscript, for example, the configuration space identification of a certain function is: the second working device configures a space [ Function ].
The base register space simulation unit 47 is used for storing parameter information of a base register space of the computer interface device 20 in the single device mode and the virtual switch mode, such as a space of base registers of respective working devices or functions. When the computer interface device 20 is in the virtual switch mode, the virtual switch supports N downstream ports and N first working devices, and the upstream ports support X functions, each downstream port supports Y functions, each first working device supports M functions, each upstream port or each function of a downstream port supports T base address register spaces, preferably, T is less than or equal to 2, and each function of each first working device supports L base address register spaces, preferably, L is less than or equal to 6.
Referring to fig. 6, the present embodiment organizes 1 upstream port and N downstream ports in an array, each of which has T base address register spaces. The present embodiment uses a base address number to indicate a specific base address register space of the upstream port, and the host 10 accesses the specific base address memory space of the upstream port by the base address number, and for example, a certain base address register space of the upstream port may be identified as an upstream port base address register space [ Function ] [ BAR ID ], where BAR ID is the base address number of a certain base address register. In addition, each first working device also has a unique device number, and the base address number can be used in combination with the device number and the function number of the first working device to jointly identify a certain base address register space of a certain function of the first working device.
When the host accesses the base address register, the TLP memory packet is sent without bus number, device number, function number and base address number, and only the memory address to be accessed is needed, so that the memory address needs to be compared with the base address space of each device to determine which base address register space of which function corresponds to which device of which device, and then accessed through the array subscript.
For example, when accessing the base register space of an upstream port, the base register space of the upstream port may be identified as: the upstream port base address register space [ function ] [ BAR_ID ], where [ function ] is the function number of a function and [ BAR_ID ] is the base address number of the base address register. When accessing a base register space of a downstream port, the base register space of the downstream port may be identified as: the device base address register space [ device ] [ function ] [ BAR_ID ] of the downstream port, wherein [ device ] is the device number corresponding to the downstream port. When accessing a base register space of a function of the first work device, the base register space may be identified as: the first working device base register space [ device function BAR ID ].
When the computer interface device 20 is operating in the single device mode, as shown in fig. 7, a Function of the second working device may be identified by a Function number, each Function may correspond to L base address register spaces, and then the device number, the Function number, and the base address number may be used to identify a Function-specific base address register space of the second working device, for example, as a second working device base address register space [ device Function ] [ BAR ID ].
Preferably, the base register spaces of the upstream port, downstream port and respective working devices are stored separately by device type, i.e. the base register spaces of each device type are isolated from each other and are each allocated space in the volatile memory area to emulate the respective base register spaces.
Referring back to fig. 3, the computer interface apparatus can realize various operations, and thus, a plurality of operation units for realizing different operations are provided in the computer interface apparatus, including a mode switching unit 51, a configuration space initializing unit 52, a base register space initializing unit 53, a configuration space reading and writing unit 54, and a base register space reading and writing unit 55. The above-mentioned operation unit may be implemented by a programmable integrated circuit, or may be implemented by hardware programming logic, or may be implemented by a software program, or may be implemented partly by hardware programming logic, or partly by software.
The switching of the operation modes of the computer interface device 20 may be achieved by external output of a hardware circuit, for example, by changing a signal output by a dial switch, or by configuring corresponding parameters by the host 10. The following describes a specific flow for implementing the operation mode switching through the configuration management operation of the host 10.
Method embodiment for realizing computer interface expansion switching:
The default operation mode of the computer interface device may be a single operation mode or a virtual switch operation mode, and no matter which operation mode is operated, at least one endpoint device needs to be presented to the host 10, and in this embodiment, the presented endpoint device is referred to as a target device. The presented target device is the second working device if in the single device mode and the first working device if in the virtual switch mode.
The host 10 may implement the modification of the operation mode by modifying the configuration space of the target device, or may implement the modification of the operation mode by modifying the base register space. Therefore, the host 10 may query the current operating mode of the computer interface device 20 using the vendor-defined command of the register, and determine whether modification is required for the current operating mode, and if so, modify parameters stored in the nonvolatile memory by sending a write request command, thereby implementing modification of the operating mode. Since the data of the operation mode is stored in the nonvolatile memory, when the computer interface device is started next time, the data of the operation mode recorded in the nonvolatile memory is read, and the updated operation mode is validated after the host 10 is restarted or after the computer interface device 20 rescans the parameters stored in the nonvolatile memory.
The following describes a workflow of the mode switching unit 51 for implementing the change of the operation mode by changing the parameters of the configuration space by the host 10 in conjunction with fig. 8. First, the user performs step S11 to read the current operation mode of the computer interface device 20 through the host 10, and then, the host 10 performs step S12 to transmit configuration space read request information to any one of the endpoint devices, wherein the endpoint device that receives the configuration space read request information is the target device 70. Alternatively, host 10 may send the configuration space read request information using vendor custom commands for PCIe DoE registers. After receiving the configuration space reading request information, the target device 70 performs step S13 to read the data of the current operation mode from the nonvolatile memory, and performs step S14 to return the read result to the host 10.
Then, the user determines whether the current working mode needs to be replaced according to the current working mode, the use requirement of the host 10, and the like, if the current working mode needs to be replaced, step S15 is executed, a command for replacing the mode is issued, step S16 is executed after the host 10 receives the command, and request information for writing the configuration space is sent to any one endpoint device, wherein the endpoint device that receives the request information for writing the configuration space is the target device 70. Next, the host computer 10 executes step S17 to write the updated data of the operation mode to the nonvolatile memory, and executes step S18 to return the result of the writing to the host computer 10.
In addition to the switching of the operating mode by modifying the parameters of the configuration space, the operating mode may also be switched by modifying the parameters of the base register space. Referring to fig. 9, first, the user performs step S21 to read the current operation mode of the computer interface device 20 through the host 10, and then, the host 10 performs step S22 to transmit base register space read request information to any one of the endpoint devices, wherein the endpoint device that has received the base register space read request information is the target device 70. Alternatively, host 10 may send the configuration space read request information using vendor custom commands for the mailbox registers. After receiving the base register space read request information, the target device 70 executes step S23 to read the data of the current operation mode from the nonvolatile memory, and executes step S24 to return the read result to the host 10.
Then, the user determines whether the current working mode needs to be replaced according to the current working mode, the use requirement of the host 10, and the like, if the current working mode needs to be replaced, step S25 is executed, and after receiving the instruction, the host 10 executes step S26 to send the request information for writing the base address register space to any one endpoint device, wherein the endpoint device that receives the request information for writing the base address register space is the target device 70. Next, the host 10 executes step S27 to write the updated data of the operation mode to the nonvolatile memory.
When the target device 70 receives the information of the switching of the operation modes, it is necessary to present different topologies to the host 10 according to the switched operation modes, referring to fig. 10, the target device 70 first executes step S31 to determine whether the current operation mode has been switched, and if not, executes step S36 to maintain the current operation mode, i.e. without changing the topology of each operation device. If the current working mode changes, the current topology structure needs to be changed, and step S32 is executed, so that the host is restarted, and when the host is restarted, the configuration space and the base register space are initialized according to the updated working mode, and the PCIe device discovery process, that is, the PCIe enumeration process, is performed again. For example, when switching from the single device mode to the virtual switch mode, the host would only need to allocate 1 bus for the single device mode, and the virtual switch would obviously need more buses, so that the host can discover more buses by re-performing the PCIe device discovery process.
Then, step S33 is executed to determine whether the switched operation mode is the virtual switch mode, and if so, step S34 is executed to present an uplink port, a plurality of downlink ports, and a plurality of first operation devices to the host 10, where each downlink port corresponds to one operation device, that is, the topology shown in fig. 2 is presented. Of course, the configuration space and base register space, respectively, also require corresponding presentation. If the result of the determination in step S33 is no, which means that the switched operation mode is the single device mode, step S35 is performed to present only one device, which is the second operation device, to the host 10.
The process of presenting the working device to the host 10 is in effect a response to the host 10's enumeration discovery process, and a response to configuration space read-write request information and a response to base register space read-write request information.
The process of configuration space initialization by configuration space initialization unit 52 for different endpoint devices is described below in conjunction with fig. 11. When the host 10 initiates a device scan for an enumeration discovery of an endpoint device, the endpoint device obtains the PCIe bus ID assigned by the host 10 and initializes registers in its configuration space, thereby providing information and corresponding capabilities of the respective endpoint device.
Firstly, step S41 is executed to receive a PCIe TLP configuration message sent by the host 10, e.g. receive configuration request information, then step S42 is executed to determine whether the TLP configuration request message is received for the first time, and read a register ID (Vendor ID), if yes, step S43 is executed to determine whether the current working mode is a virtual switch mode, if yes, step S44 is executed to initialize configuration spaces of an upstream port, a downstream port, and a first working device, and derive corresponding buses, working devices, and corresponding functions of the upstream port, the downstream port, and each first working device according to a target Bus in the configuration request and a topology result to be presented, where specifically, a Bus usp.bus of the derived upstream port is a target Bus in the configuration request message, a Bus dsp.bus of the derived downstream port is usp.bus+1, a device dsp.dev allocation range of the derived downstream port is [0, N-1], and a bus.bus allocation range of the derived first working device is [ dsp.bus+1, dsp.bus+n ].
If the result of the determination in step S42 is no, it indicates that the register ID is not currently received for the first time, and step S46 is directly performed, where the TLP configuration request information is responded to according to the PCIe enumeration discovery procedure until the enumeration discovery procedure is completed.
If the judgment result in the step S43 is no, the current working mode is the single device mode, the step S45 is executed, the configuration space of the second working device is initialized, and the buses, devices and functions in the configuration request message are used as the buses, devices and functions of the second working device.
After the configuration space is initialized, all PCIe TLP configuration messages initiated by the host 10 that are subsequently received can find configuration spaces simulated by each device according to the target bus, the device and the function to perform read-write operation. The following describes the procedure of locating the configuration space of each endpoint device when the configuration space read/write unit 54 performs configuration space read/write with reference to fig. 12.
Firstly, step S51 is performed to receive a PCIe TLP configuration message sent by the host 10, for example, receive configuration space read request information, and then step S52 is performed to parse the received message, obtain information of a target Bus, a target Device, and a target Function in the configuration message, and find a corresponding Device type according to a Bus ID.
Then, step S53 is executed to determine whether the bus of the configuration packet is consistent with the bus of the upstream port, for example, whether the bus ID in the configuration packet is identical with the bus ID of the upstream port, if so, step S54 is executed to determine, according to the function number in the received packet, which function configuration space in the upstream port needs to be read and written, and the function configuration space corresponding to the upstream port is directly located, and access operations such as reading and writing can be performed on the configuration space of the upstream port.
If the determination result in step S53 is no, step S55 is executed to determine whether the bus of the configuration packet is a bus of a downstream port, for example, whether the bus ID in the configuration packet is the same as the bus ID of the downstream port, if so, step S56 is executed, where the configuration space of the downstream port is directly located, for example, the configuration space of which function of which device of which downstream port is accessed by the current operation is determined according to the device number and the function number in the packet, and access operations such as reading and writing can be performed on the configuration space corresponding to the downstream port.
If the determination result in step S55 is no, step S57 is executed to determine whether the bus of the configuration message is a bus of the first working device, for example, to determine whether the bus ID in the configuration message is the same as the bus ID of the first working device, if so, step S58 is executed to directly locate the configuration space of the working device, for example, to determine which function of the first working device is accessed by the current operation according to the device number and the function number in the message, and to perform access operations such as reading and writing on the configuration space corresponding to the working device.
If the result of the determination in step S57 is no, in step S59, information that the message is an illegal message, for example, information that the response message does not support is returned, and an error processing flow is entered.
As can be seen from the above description, the TLP configuration packet includes the target BDF information to be accessed, that is, the information of the target bus, the device and the function to be accessed, so that the corresponding configuration space can be accessed by directly using the bus number, the device number and the function number in the BDF information. Therefore, whether the uplink port, the downlink port or the first working device is accessed currently can be known according to the bus number in the BDF information, and after the type of the device to be accessed is determined, if the uplink port is accessed currently, the uplink port configuration space [ Function ] can be directly read and written according to the Function number in the BDF information, namely the configuration space of the corresponding Function of the uplink port can be directly read and written. If the current access is to the downstream port, it is also necessary to determine the Device number and Function number to be accessed according to the BDF information in the TLP configuration packet, and determine which downstream port and which Function are currently accessed according to the Device number and Function number, and read and write configuration spaces of the corresponding Device and corresponding Function, such as a read and write downstream port configuration space [ Device ] [ Function ].
If the first working device is read and written currently, since the device numbers of all the first working devices are set to 0, the array index number can only be deduced through the bus, that is, the device number to be accessed is deduced, and the device number to be accessed can be obtained through the following formula calculation: device=target bdf.bus-dsp.bus-1, where target bdf.bus is the bus number in the TLP configuration packet and dsp.bus is the bus number of the downstream port. After determining which first working device needs to be accessed, accessing a corresponding configuration space according to the determined device number and Function number, such as reading and writing the first working device configuration space [ device ] [ Function ].
The following describes an initialization procedure performed when the base register space initialization unit 53 implements base register space allocation initiated by the host 10. First, the host 10 obtains the physical addresses of the various internal spaces supported by the plurality of endpoint devices or functions mapped in the memory of the host 10, i.e., the base addresses of the base address register space. After this process is complete, the PCIe TLP memory packet originated by the host 10 may be responded to, i.e., in response to the host 10 originated access to the base register space.
In addition, when initializing the configuration space, it is necessary to plan in advance what way to open the internal resources of each endpoint device to the host 10 for access, for example, the number and size of base register spaces supported by each endpoint device, in which base register space the registers corresponding to each endpoint device are planned to be presented, and the like. The host 10 allocates base addresses of base address registers corresponding to different devices or functions according to reporting capabilities of the different devices or functions in the base address registers of the respective configuration spaces, and writes the base addresses into the base address registers of the corresponding configuration spaces through PCIe TLP configuration messages according to access modes of the configuration space read-write units.
After initializing the base address register space, the computer interface device 20 receives all PCIe TLP memory messages initiated by the host 10, and can find the base address register space simulated by each device according to the access address in the messages and perform read-write operation.
The following describes a procedure in which the base register space read-write unit 55 realizes read-write access to the base register space. If the computer interface device works in the single device mode, judging whether the memory address in the received PCIe TLP memory message is in the only base register space range supported by the second working device in the single device mode; if the error is not within the range, entering an error processing flow; if the address is within the range, the address is read and written normally.
If the device is operating in the virtual switch mode, it is required to quickly query which segment of the base register space corresponding to which device or function the address belongs according to the address in the PCIe TLP memory packet, for example, the quick lookup mode may be a plurality of modes, and the first mode is that, when the base register space is initialized, addresses of base registers of all devices or functions are ordered according to the size, because the host 10 can ensure that addresses allocated to base registers of different devices or functions do not overlap, so that when the device is searched, which segment of the base register space corresponding to which device or function the specific address belongs can be quickly found through a binary algorithm; the second way is to build a hash function, map address segments of different base address registers to spaces of different devices or functional base address registers, and directly calculate according to the hash function during searching. After locating which device, function, or base address register is accessed by the PCIe TLP memory packet, a difference (offset) between the memory address in the packet and the base address of the base address register may be calculated, and a specific address may be read from or written to a corresponding base address register space array element.
Since the TLP memory packet contains no BDF information to be accessed, only one memory information, that is, only memory address information, the computer interface device 20 determines, according to the memory address information in the packet, which function of which base register space the current destination address to be accessed is, which device is. For example, if the base register space of the upstream port is to be accessed, the corresponding base register space is accessed through the upstream base register space [ function ] [ BAR_ID ]. If the base register space of the downstream port is to be accessed, the access is performed through the downstream base register space [ device function ] [ BAR_ID ], and if the base register space of one of the first working devices is to be accessed, the access is performed through the first working device base register space [ device function ] [ BAR_ID ].
Because the technical interface device can work in two different modes, a user can flexibly set the working mode of the computer interface device according to the actual use requirement, and can realize the switching of the working mode by executing simple operation, thereby being capable of conveniently realizing the expansion of the computer interface and meeting the requirements of different use scenes.
Finally, it should be emphasized that the foregoing is merely a preferred embodiment of the present invention, and is not intended to limit the invention, but rather that various changes and modifications can be made by those skilled in the art without departing from the spirit and principles of the invention, and any modifications, equivalent substitutions, improvements, etc. are intended to be included within the scope of the present invention.
Claims (10)
1. A method for implementing extended switching of a computer interface, comprising:
The method comprises the steps that a host acquires working mode information of computer interface equipment, and whether the working mode of the computer interface equipment needs to be replaced is determined according to the working mode information of the computer interface equipment;
After the host switches the working mode of the computer interface device from a single device mode to a virtual switch mode, presenting a virtual switch to the host, wherein the virtual switch comprises an uplink port and more than two downlink ports, and further presents more than two first working devices, each presented first working device corresponds to one downlink port, the uplink port, each downlink port and each first working device are configured with corresponding configuration spaces, and each uplink port, each downlink port and each first working device is allocated with corresponding base register space;
after the host switches the working mode of the computer interface device from the virtual switch mode to the single device mode, only one second working device is presented to the host, wherein the second working device is configured with a corresponding configuration space and is allocated with a corresponding base address register space.
2. The method for implementing computer interface extension switching of claim 1, wherein:
the host switching the operating mode of the computer interface device from a single device mode to a virtual switch mode includes: the host computer modifies the data of the nonvolatile memory of the computer interface device, the host computer is restarted, and the configuration space and the base register space are initialized according to the updated working mode when the host computer is restarted;
each first working device corresponds to at least one first function, each first working device has a unique device number, each first function of each first working device has a corresponding function number, and each first function of each first working device is identified by using the device number and the function number.
3. The method for implementing computer interface extension switching of claim 1, wherein:
The host switching the operating mode of the computer interface device from a single device mode to a virtual switch mode includes: the host modifying data of a non-volatile memory of the computer interface device;
The base address register spaces of the functions of the uplink port, the base address register spaces of the functions of the downlink port and the base address register spaces of the first functions of each first working device are respectively provided with corresponding base address numbers.
4. A method of implementing a computer interface extension handoff as claimed in claim 3, wherein:
each first working device corresponds to at least one first function, each first function of each first working device has a corresponding function number, and a specific base address register space of each first function of each first working device is identified by using the device number, the function number and the base address number.
5. A method of implementing a computer interface extension switch as claimed in any one of claims 1 to 4 wherein:
the method further includes initializing a configuration space of the computer interface device: and when configuration request information sent by the host is received for the first time, reading a register ID, judging whether the current working mode is a virtual switch mode, if so, initializing configuration spaces of the uplink port, the downlink port and the first working equipment, and deducing a corresponding uplink port, a corresponding downlink port, the first working equipment and a corresponding first function according to a target bus in the configuration request information and a topological structure to be presented.
6. A method of implementing a computer interface extension switch as claimed in any one of claims 2 to 4 wherein:
the method further includes initializing a base register space of the computer interface device: and the host acquires the physical address of each first working device or the internal space supported by the first function mapped to the host memory.
7. An apparatus for implementing computer interface expansion switching, characterized in that:
a computer interface device having an operation mode storage unit for storing an operation mode of the computer interface device, wherein the operation mode includes a single device mode and a virtual switch mode;
When the computer interface device is in a virtual switch mode, presenting a virtual switch to a host, wherein the virtual switch comprises an uplink port, more than two downlink ports and more than two first working devices, each presented first working device corresponds to one downlink port, the uplink port, each downlink port and each first working device are configured with corresponding configuration spaces, and the uplink port, each downlink port and each first working device are distributed with corresponding base address register spaces;
In the single device mode, only one second working device is presented to the host, the second working device being configured with a corresponding configuration space and being allocated a corresponding base register space.
8. The apparatus for implementing computer interface expansion switching of claim 7, wherein:
the computer interface device is also provided with a configuration space simulation unit;
The configuration space simulation unit simulates configuration spaces corresponding to the functions of the uplink port, the downlink ports and the first working devices when the computer interface device is in the virtual switch mode;
and the computer interface simulates a configuration space corresponding to each second function of the second working equipment by the configuration space simulation unit under the single equipment mode.
9. The apparatus for implementing a computer interface extension switch as claimed in claim 8, wherein:
the computer interface device is also provided with a base address register space simulation unit;
The computer interface device is in the virtual switch mode, and the base address register space simulation unit stores base address numbers of base address register spaces of functions of the uplink ports, base address numbers of base address register spaces of functions of the downlink ports, device numbers of the first working devices, function numbers of the first functions of the first working devices and base address numbers of base address registers of the first functions;
in the single device mode, the base address register space simulation unit stores the device number of the second working device, the function number of each second function of the second working device, and the base address number of each base address register of each second function.
10. The apparatus for implementing a computer interface extension switch as claimed in claim 9, wherein:
The configuration space of the uplink port, the downlink port and the first working equipment, which are stored by the configuration space simulation unit, are stored in an isolated mode according to equipment types;
and the base address register space of the uplink port, the downlink port and the first working equipment stored by the base address register space simulation unit is isolated and stored according to equipment types.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202410459672.2A CN118093481B (en) | 2024-04-17 | 2024-04-17 | Method and device for realizing computer interface expansion switching |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202410459672.2A CN118093481B (en) | 2024-04-17 | 2024-04-17 | Method and device for realizing computer interface expansion switching |
Publications (2)
Publication Number | Publication Date |
---|---|
CN118093481A true CN118093481A (en) | 2024-05-28 |
CN118093481B CN118093481B (en) | 2024-08-13 |
Family
ID=91153394
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202410459672.2A Active CN118093481B (en) | 2024-04-17 | 2024-04-17 | Method and device for realizing computer interface expansion switching |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN118093481B (en) |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US11106616B1 (en) * | 2019-11-21 | 2021-08-31 | Xilinx, Inc. | Virtualized peripheral component interconnect express (PCIe) device |
CN113904938A (en) * | 2021-09-28 | 2022-01-07 | 北京大禹智芯科技有限公司 | System and method for dynamically configuring PCIe terminal equipment |
CN116521596A (en) * | 2023-06-29 | 2023-08-01 | 北京大禹智芯科技有限公司 | PCIe Switch simulator realization method and device based on Qemu virtual environment |
CN116719606A (en) * | 2023-06-12 | 2023-09-08 | 北京芯素科技有限公司 | Accelerator supporting hardware virtualization and data access method thereof |
-
2024
- 2024-04-17 CN CN202410459672.2A patent/CN118093481B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US11106616B1 (en) * | 2019-11-21 | 2021-08-31 | Xilinx, Inc. | Virtualized peripheral component interconnect express (PCIe) device |
CN113904938A (en) * | 2021-09-28 | 2022-01-07 | 北京大禹智芯科技有限公司 | System and method for dynamically configuring PCIe terminal equipment |
CN116719606A (en) * | 2023-06-12 | 2023-09-08 | 北京芯素科技有限公司 | Accelerator supporting hardware virtualization and data access method thereof |
CN116521596A (en) * | 2023-06-29 | 2023-08-01 | 北京大禹智芯科技有限公司 | PCIe Switch simulator realization method and device based on Qemu virtual environment |
Also Published As
Publication number | Publication date |
---|---|
CN118093481B (en) | 2024-08-13 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US20200278880A1 (en) | Method, apparatus, and system for accessing storage device | |
JP6014271B2 (en) | Data processing system and data processing method | |
US6901480B2 (en) | Method and apparatus for reconfiguring striped logical devices in a disk array storage | |
US11966612B2 (en) | Solid-state disk (SSD) data migration | |
US6850997B1 (en) | System, method, and program for determining the availability of paths to a device | |
US10534541B2 (en) | Asynchronous discovery of initiators and targets in a storage fabric | |
KR20180012181A (en) | Self-Configuring SSD Multi-Protocol Support in Host-less Environment | |
US8615586B2 (en) | Discovery of logical images at storage area network endpoints | |
US9378103B2 (en) | Coordination techniques for redundant array of independent disks storage controllers | |
CN115562738B (en) | Port configuration method, component and hard disk expansion device | |
CN112148229B (en) | Method for accelerating read-write efficiency of nonvolatile memory under Feiteng server platform | |
JP2021508878A (en) | Flash memory controller, SD card device, method used in flash memory controller, and host device coupled to SD card device | |
JP4738069B2 (en) | Data storage system and method for managing logical paths in a data storage system | |
CN118093481B (en) | Method and device for realizing computer interface expansion switching | |
CN113377389A (en) | Data processing method and device, computer readable storage medium and processor | |
CN110765060B (en) | MDIO bus-to-parallel bus conversion method and device, equipment and medium | |
JP2014179066A (en) | Storage control device, storage system, and storage control method | |
JP2004021867A (en) | Information processing system | |
CN116932451A (en) | Data processing method, host and related equipment | |
US20170109092A1 (en) | Selective initialization of storage devices for a logical volume | |
CN115033186B (en) | Dual-port NVMe controller and read-write command processing method | |
US11500580B2 (en) | Memory system | |
JPH1020906A (en) | Data processor and data processing method | |
JP2866376B2 (en) | Disk array device | |
JP2866375B2 (en) | Computer system and magnetic disk unit |
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 |