Port configuration method, device, equipment, medium and product
By automatically identifying the supported rates of optical modules and performing multi-level rate matching for port configuration, the problem of low efficiency in manual configuration in white-box switches is solved, achieving efficient and accurate port configuration and reducing operation and maintenance costs.
Patent Information
- Application Number
- CN202511778578.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-28
- Publication Date
- 2026-02-17
AI Technical Summary
In existing technologies, white-box switches require manual configuration of port rates when replacing optical modules with different rates, resulting in low operational efficiency, high error rates, high maintenance costs, and compatibility issues.
By automatically identifying the supported rate of the optical module when it is inserted, performing multi-level rate matching, and combining the current port status for atomic configuration, automated port configuration is achieved.
It improves the efficiency and accuracy of port configuration, reduces operation and maintenance costs, and better leverages port performance.
Smart Images

Figure CN121547707A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer network technology, and in particular to a port configuration method, apparatus, device, medium, and product. Background Technology
[0002] As data centers continue to expand, white-box switches are widely used due to their openness and flexibility. A white-box switch is a network switching device that separates hardware and software. Its hardware uses general-purpose commercial chips and components, while its software can run third-party or open-source operating systems (such as CumulusLinux), allowing users to customize its functionality.
[0003] The current SONiC open-source system supports querying optical module information (e.g., via commands). When replacing optical modules with different speeds (e.g., 1G / 10G, 10G / 25G, 40G / 100G / 200G / 400G), the port speed needs to be manually configured via CLI based on the optical module information.
[0004] Existing technologies have the following pain points: manual configuration of port rates is inefficient; optical modules in large data centers are frequently replaced; manual configuration is time-consuming and prone to errors, resulting in high maintenance costs; and there are compatibility issues, such as high-speed optical modules being inserted into low-speed ports, causing links to fail to be established, or low-speed modules failing to utilize the performance of high-speed ports. Summary of the Invention
[0005] This invention provides a port configuration method, apparatus, device, medium, and product to achieve automatic identification of optical modules and dynamic port configuration based on the optical module identification results.
[0006] According to a first aspect of the present invention, a port configuration method is provided, comprising:
[0007] When the optical module insertion port is detected, the optical module's supported rate is obtained;
[0008] Multi-level rate matching is performed based on the supported rate of the optical module to obtain the rate matching result of the port;
[0009] Based on the current state of the port and the rate matching result, the port is configured atomically.
[0010] According to a second aspect of the present invention, a port configuration apparatus is provided, comprising:
[0011] An information recognition module is used to obtain the optical module's supported rate when an optical module insertion port is detected;
[0012] A configuration determination module is used to perform multi-level rate matching based on the rate supported by the optical module to obtain the rate matching result of the port;
[0013] The port configuration module is used to perform atomic configuration on the port based on the current state of the port and the rate matching result.
[0014] According to a third aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0015] At least one processor; and
[0016] A memory communicatively connected to the at least one processor; wherein,
[0017] The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the port configuration method according to any embodiment of the present invention.
[0018] According to a fourth aspect of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium storing computer instructions for causing a processor to execute and implement the port configuration method described in any embodiment of the present invention.
[0019] According to a fifth aspect of the present invention, embodiments of the present invention also provide a computer program product, the computer program product including a computer program, which, when executed by a processor, implements the port configuration method of any embodiment of the present invention.
[0020] The technical solution of this invention involves obtaining the optical module's supported optical rate when an optical module is detected being inserted into a port; performing multi-level rate matching based on the supported optical rate to obtain the port's rate matching result; and then atomically configuring the port based on its current state and the rate matching result. By automatically identifying the optical module's supported optical rate upon detection of insertion, and intelligently matching the port's supported rate to meet the optical module's requirements, a rate matching result is obtained, and the port is automatically configured based on this result. This achieves automatic identification of optical module attributes and dynamic, automated port configuration, improving configuration efficiency and accuracy, thereby reducing maintenance costs and better utilizing port performance.
[0021] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description
[0022] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0023] Figure 1 This is a flowchart of a port configuration method provided according to Embodiment 1 of the present invention;
[0024] Figure 2 This is a flowchart of a port configuration method provided according to Embodiment 2 of the present invention;
[0025] Figure 3 This is an example flowchart of a port configuration method provided according to Embodiment 2 of the present invention;
[0026] Figure 4 This is a schematic diagram of a port configuration device according to Embodiment 3 of the present invention;
[0027] Figure 5 This is a schematic diagram of the structure of an electronic device that implements an embodiment of the present invention. Detailed Implementation
[0028] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0029] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0030] Example 1
[0031] Figure 1This is a flowchart illustrating a port configuration method provided in Embodiment 1 of the present invention. This embodiment is applicable to the dynamic configuration of optical modules in a SONIC system. The method can be executed by a port configuration device, which can be implemented in hardware and / or software and can be configured in an electronic device. Figure 1 As shown, the method includes:
[0032] S110. When the optical module insertion port is detected, obtain the optical module's supported rate.
[0033] In this embodiment, an optical module can be understood as an optoelectronic device that converts electrical signals to optical signals. A port can be understood as an interface that physically connects to the optical module. The supported rate of the optical module can be understood as information used to characterize the rate characteristics of the optical module itself.
[0034] Specifically, when an optical module insertion port is detected, the processor can access the optical module's memory via the I2C bus or other means to read the optical module's supported optical rate stored therein.
[0035] For example, in the Sonic system, the insertion of optical modules can be detected through the xcvrd process. When an optical module is detected being inserted into the port, xcvrd can obtain the optical module's supported speed. The xcvrd process is a daemon process in the Sonic system specifically designed to monitor and manage the status of optical modules (transceivers, such as SFP and QSFP), responsible for collecting hardware information (including supported speeds) and operational metrics of the optical modules.
[0036] S120. Perform multi-level rate matching based on the optical module's supported rate to obtain the port's rate matching result.
[0037] In this embodiment, the rate matching result can be understood as the port rate matching result adapted to the optical module.
[0038] Specifically, the processor can perform multi-level rate matching with the port's supported rate according to a predefined compatibility matrix based on the optical module's supported rate, and obtain the rate that best matches the port's supported rate as the rate matching result.
[0039] For example, in the sonic system, the xcvrd process can perform multi-level rate matching based on the optical module's supported rate to determine the port's rate matching result.
[0040] S130. Based on the current state of the port and the rate matching result, perform atomic configuration on the port.
[0041] In this embodiment, the current state includes configuration states such as the current port speed. Atomic configuration can be understood as the overall configuration method being executed as an indivisible whole, thereby fundamentally avoiding intermediate states of inconsistent device configurations. It is either fully executed or not executed at all. There is no state of partial execution.
[0042] Specifically, the processor can obtain the current state of the port and save it as a backup configuration for subsequent rollback. It first disables the port to avoid configuration conflicts, then sets the port's speed using the speed matching result, and finally restarts the port. By detecting the port's link status, if the link status is abnormal at a set time, a rollback operation is automatically performed to restore the port's original configuration according to the backup configuration.
[0043] For example, the portsorch service can be used to perform atomic configuration of ports based on their current state and rate matching results. Portsorch is a port orchestration service in Sonic that is responsible for managing the lifecycle, state transitions, and configuration applications of all physical and logical ports on the switch, serving as the "central control center" for port management.
[0044] The technical solution of this invention involves obtaining the optical module's supported optical rate when an optical module is detected being inserted into a port; performing multi-level rate matching based on the optical module's supported rate to obtain the port's rate matching result; and then atomically configuring the port based on its current state and the rate matching result. By automatically identifying the optical module's supported optical rate upon detection of insertion and intelligently matching the port's supported rate to meet the optical module's requirements, a rate matching result is obtained, and the port is automatically configured based on this result. This achieves automatic identification of the optical module's rate and dynamic, automated port configuration, improving configuration efficiency and accuracy, thereby reducing maintenance costs and better utilizing port performance.
[0045] Example 2
[0046] Figure 2 This is a flowchart of a port configuration method provided in Embodiment 2 of the present invention. This embodiment is a further refinement of the above embodiment. Figure 2 As shown, the method includes:
[0047] S201. Acquire the hardware-level mutex lock and perform a data read operation on the memory in the optical module.
[0048] In this embodiment, a hardware-level mutex lock can be understood as a mechanism that uses atomic instructions provided by the CPU to implement atomic operations on the lock, ensuring that only one thread can acquire the lock at any given time in a multi-threaded environment. The memory can be understood as a device used to store the attributes of the optical module, such as an electrically erasable programmable read-only memory (EEPROM).
[0049] Specifically, the processor can acquire a hardware-level mutex and perform data read operations on the memory in the optical module via a bus.
[0050] S202. If the reading is successful, the optical module's supported rate is obtained.
[0051] In this embodiment, the optical module's supported rate can be understood as the optical module's transmission rate.
[0052] Specifically, if the data reading is successful, the processor can deduce the optical module's supported rate from the read data.
[0053] S203. If the read fails, the read will be retried a limited number of times until the read finally fails and the mutex is released.
[0054] Specifically, if data reading fails, the processor can employ an exponential backoff strategy and perform a limited number of retries. The exponential backoff strategy can be understood as a retry mechanism where the interval between each retry increases exponentially when the operation fails. If the reading is successful, the supported optical module rate is obtained. If the reading fails after a limited number (i.e., a preset number) of retries, the mutex is released, and a failure message is transmitted.
[0055] S204. Obtain the list of port supported speeds.
[0056] In this embodiment, the port supported rate list can be understood as the set of transmission rates supported by the port.
[0057] Specifically, the processor can obtain a pre-defined list of port supported rates from the storage medium or other storage methods.
[0058] S205. If the optical module's supported rate matches the first supported rate in the supported rate list, then the first supported rate is taken as the port's first-level rate matching result.
[0059] In this embodiment, the first supported rate can be understood as the port supported rate that is consistent with the optical module's supported rate. The first-level rate matching result is used to characterize completely identical rate matching results.
[0060] Specifically, if the optical module supports the same rate as the first supported rate in the supported rate list, the processor can use the first supported rate as the first-level rate matching result for the port.
[0061] S206. Otherwise, if there is a second supported rate in the supported rate list whose error with the optical module's supported rate is less than the first threshold, then the second supported rate is used as the secondary rate matching result.
[0062] In this embodiment, the first threshold is a threshold set to limit the error. The second supported rate can be understood as the port supported rate within the error threshold. The second-level rate matching result can be understood as a result representing an incomplete match.
[0063] Specifically, if there is no port support rate in the supported rate list that is exactly the same as the optical module's supported rate, the difference between the optical module's supported rate and the port support rate in the supported rate list is calculated, and the error value between the two is determined. The port support rate with an error less than the first threshold is the second supported rate, and the second supported rate can be used as the secondary rate matching result.
[0064] S207. Otherwise, if there is a third supported rate in the supported rate list that is higher than the optical module's supported rate but less than a set multiple, then the third supported rate will be used as the third-level rate matching result.
[0065] In this embodiment, the set multiplier can be understood as a multiplier used to characterize the deviation selection. The third support rate can be understood as the port support rate with a larger error relative to the second support rate.
[0066] Specifically, if there is no supported rate in the supported rate list that has an error of less than the first threshold with respect to the supported rate of the optical module, then a third supported rate that is higher than the supported rate of the optical module and less than a set multiple (e.g., 1.2 times) with respect to the supported rate of the optical module is selected from the supported rate list, and the third supported rate is used as the third-level rate matching result.
[0067] S208. Otherwise, the lowest rate in the supported rate list will be used as the fourth-level rate matching result.
[0068] In this embodiment, the level 4 rate matching result can be understood as the lowest rate supported by the port.
[0069] Specifically, if none of the above methods can match, the processor can use the lowest rate in the supported rate list as the fourth-level rate matching result.
[0070] Furthermore, based on the above embodiments, after performing multi-level rate matching according to the optical module's supported rate to obtain the port's rate matching result, the method further includes:
[0071] Based on the rate matching results, the port rate information is generated in the database format and reported to the database.
[0072] In this embodiment, the database can be understood as a database used to store the status and configuration of optical modules. For example, it can be a distributed key-value database (Redis-based database). Through the database, collaboration and status sharing between different components can be achieved. The database format is the format in which attribute data is stored in the database.
[0073] Specifically, the sonic system requires different components to determine and configure port rates. During port rate configuration, it relies on the port rates determined by other components. The xcvrd process mentioned above can then generate port rate information according to a database format using the rate matching results and report it to the APP_DB (Application Database). In the SONiC (Software for Open Networking in the Cloud) network operating system, APP_DB is a core in-memory database that serves as the communication hub between network application components (such as routing management and port management) and the underlying system orchestration agent. Its design goal is to achieve efficient inter-process communication and data synchronization. Subsequently, the portsorch service reads the port configuration information from the database to obtain the rate matching results.
[0074] S209. Determine the rollback backup configuration based on the current status of the port.
[0075] In this embodiment, the rollback backup configuration can be understood as configuration information used to roll back and restore the current state.
[0076] Specifically, the processor can use the current configuration of the port as a rollback backup configuration if the current status is normal.
[0077] S210, disable the port and set the port rate according to the rate matching result.
[0078] In this embodiment, the port rate can be understood as the actual operating speed of the port during operation.
[0079] Specifically, the processor can disable ports to avoid configuration conflicts and set the port rate based on the above configuration results.
[0080] S211. Re-enable the port and verify the link status of the link where the port is located.
[0081] In this embodiment, the link status can be understood as the status used to characterize the connection and operation of the port.
[0082] Specifically, after configuration, the processor can restart the port and verify the link status of the link to which the port is located. The link status is mainly reported to the STATE DB database through physical or protocol mechanisms. In the SONiC white-box switch system, STATE_DB is a central database used to store the real-time operating status and dynamic information of the devices. It mainly acts as a "real-time bulletin board" for system status, ensuring status sharing and collaborative work among different components.
[0083] S212. If the link status remains abnormal for a set period of time, a rollback operation will be performed based on the rollback backup configuration.
[0084] In this embodiment, the set time can be understood as the set abnormal duration threshold time.
[0085] Specifically, if the link status remains abnormal within the set time, the processor can perform a rollback operation based on the rollback backup configuration to restore the port to its original configuration. If the link status is normal, it indicates that the port configuration was successful.
[0086] S213. If the link status is normal, then the port configuration is successful.
[0087] The technical solution of this invention automatically interrupts other processes and triggers the configuration process by detecting the insertion of an optical module. It automatically reads the supported optical module rate based on the bus using mutex locks and a limited number of retries, thus handling bus conflicts. Through multi-level rate matching between the optical module's supported rate and the port's supported rate, and following a decision logic of precise matching, backward compatibility, and limited upward compatibility, it achieves port rate compatibility matching, improving the adaptability between port rate and optical module rate, and thus better utilizing port performance. By first disabling the port, then performing rate configuration and verification, and automatically rolling back in abnormal states, it achieves automatic port rate configuration, improving configuration efficiency, reducing service interruptions, and lowering operation and maintenance costs.
[0088] For example, a specific example can be used as a demonstration. Figure 3 Here is an example flowchart of a port configuration method provided in Embodiment 2 of the present invention, as shown below. Figure 3As shown, in the sonic system, when the switch starts up or is running, xcvrd starts up and begins to listen for the insertion and removal events and status changes of optical modules in the system. At this time, when a 10G optical module is inserted into a 25G physical port, xcvrd detects the insertion of the optical module. It reads the data in the EEPROM of the optical module through the underlying driver to determine that the module supports a speed of 10G. At the same time, it reads the list of supported speeds for this port from the APP DB database, which includes 25G and 10G. Then, through the multi-level speed matching strategy of the port, it matches 10G as the first-level speed matching result, and generates configuration information for 10G in the database format and reports it to the APP DB database. When data changes in the APP DB database, the portsorch service is triggered to read the new 10G speed configuration from the database, lock the port, save its current state as a rollback backup configuration, and disable the port (set_admin_state(DOWN)). Then, the port speed is set to 10G, and the port state is set to set_admin_state(UP). After waiting one second, the port's oper status is read from the STATE DB database. If the port is UP, the link is normal, and the configuration is complete. If the link fails to establish itself, the rollback_config() function is called, triggering a rollback operation that automatically reverts to the original configuration of the physical port according to the rollback backup configuration.
[0089] Example 3
[0090] Figure 4 This is a schematic diagram of a port configuration device provided in Embodiment 3 of the present invention. Figure 4 As shown, the device includes:
[0091] Information recognition module 41 is used to obtain the optical module supported rate of the optical module when the optical module insertion port is detected;
[0092] The configuration determination module 42 is used to perform multi-level rate matching based on the rate supported by the optical module to obtain the rate matching result of the port;
[0093] The port configuration module 43 is used to perform atomic configuration on the port based on the current state of the port and the rate matching result.
[0094] The technical solution of this invention involves obtaining the optical module's supported optical rate when an optical module is detected being inserted into a port; performing multi-level rate matching based on the supported optical rate to obtain the port's rate matching result; and then atomically configuring the port based on its current state and the rate matching result. By automatically identifying the optical module's supported optical rate upon detection of insertion and intelligently matching the port's supported rate to meet the optical module's requirements, a rate matching result is obtained, and the port is automatically configured based on this result. This achieves automatic identification of optical module attributes and dynamic and automated port configuration, improving configuration efficiency and accuracy, thereby reducing maintenance costs and better utilizing port performance.
[0095] Furthermore, the information recognition module 41 is specifically used for:
[0096] Acquire a hardware-level mutex lock and perform a data read operation on the memory in the optical module;
[0097] If the read is successful, the supported rate of the optical module will be determined.
[0098] If the read fails, the read will be retried a limited number of times until the read finally fails and the mutex is released.
[0099] Furthermore, the configuration determination module 42 is specifically used for:
[0100] If the optical module's supported rate matches the first supported rate in the supported rate list, then the first supported rate is taken as the first-level rate matching result of the port;
[0101] Otherwise, if there is a second supported rate in the supported rate list that has an error of less than the first threshold with the supported rate of the optical module, then the second supported rate is used as the second-level rate matching result;
[0102] Otherwise, if there is a third supporting rate in the list of supported rates that is higher than the optical module's supported rate but less than a set multiple, then the third supporting rate will be used as the third-level rate matching result.
[0103] Otherwise, the lowest rate in the supported rate list will be used as the fourth-level rate matching result.
[0104] Furthermore, the port configuration module 43 is specifically used for:
[0105] Determine the rollback backup configuration based on the current status of the port;
[0106] Disable the port and set the port rate according to the rate matching result;
[0107] Re-enable the port and verify the link status of the link to which the port is located;
[0108] If the link status remains abnormal for a set period of time, a rollback operation will be performed based on the rollback backup configuration.
[0109] If the link status is normal, then the port configuration is successful.
[0110] Optionally, the device further includes a configuration information generation module.
[0111] The configuration information generation module is used to generate configuration information for the port according to the database format and report it to the database after the port rate matching result is obtained by performing multi-level rate matching based on the rate supported by the optical module.
[0112] The port configuration device provided in the embodiments of the present invention can execute the port configuration method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of executing the method.
[0113] Example 4
[0114] Figure 5 A schematic diagram of an electronic device 50 that can be used to implement embodiments of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.
[0115] like Figure 5 As shown, the electronic device 50 includes at least one processor 51 and a memory, such as a read-only memory (ROM) 52 or a random access memory (RAM) 53, communicatively connected to the at least one processor 51. The memory stores computer programs executable by the at least one processor. The processor 51 can perform various appropriate actions and processes based on the computer program stored in the ROM 52 or loaded from storage unit 58 into the RAM 53. The RAM 53 can also store various programs and data required for the operation of the electronic device 50. The processor 51, ROM 52, and RAM 53 are interconnected via a bus 54. An input / output (I / O) interface 55 is also connected to the bus 54.
[0116] Multiple components in electronic device 50 are connected to I / O interface 55, including: input unit 56, such as keyboard, mouse, etc.; output unit 57, such as various types of monitors, speakers, etc.; storage unit 58, such as disk, optical disk, etc.; and communication unit 59, such as network card, modem, wireless transceiver, etc. Communication unit 59 allows electronic device 50 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0117] Processor 51 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 51 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 51 performs the various methods and processes described above, such as port configuration methods.
[0118] In some embodiments, the port configuration method may be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 58. In some embodiments, part or all of the computer program may be loaded and / or installed on electronic device 50 via ROM 52 and / or communication unit 59. When the computer program is loaded into RAM 53 and executed by processor 51, one or more steps of the port configuration method described above may be performed. Alternatively, in other embodiments, processor 51 may be configured to execute the port configuration method by any other suitable means (e.g., by means of firmware).
[0119] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0120] Computer programs used to implement the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0121] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0122] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0123] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or middleware components (e.g., application servers), or frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.
[0124] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.
[0125] In one embodiment, the present invention further includes a computer program product, which includes a computer program that, when executed by a processor, implements the port configuration method of any embodiment of the present invention.
[0126] In implementing the computer program product, computer program code for performing the operations of this invention can be written in one or more programming languages or a combination thereof. Programming languages include object-oriented programming languages such as Java, Smalltalk, and C++, as well as conventional procedural programming languages such as C or similar languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0127] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.
[0128] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
Claims
1. A port configuration method, characterized in that, include: When the optical module insertion port is detected, the optical module's supported rate is obtained; Multi-level rate matching is performed based on the supported rate of the optical module to obtain the rate matching result of the port; Based on the current state of the port and the rate matching result, the port is configured atomically.
2. The method according to claim 1, characterized in that, The step of obtaining the optical module's supported rate includes: Acquire a hardware-level mutex lock and perform a data read operation on the memory in the optical module; If the read is successful, the supported rate of the optical module can be obtained from the parsing. If the read fails, the read will be retried a limited number of times until the read finally fails and the mutex is released.
3. The method according to claim 1, characterized in that, Based on the optical module's supported rate, multi-level rate matching is performed to obtain the port's rate matching result, including: Obtain the list of port supported speeds for the specified port; If the optical module's supported rate matches the first supported rate in the supported rate list, then the first supported rate is taken as the first-level rate matching result of the port; Otherwise, if there is a second supported rate in the supported rate list that has an error of less than the first threshold with the supported rate of the optical module, then the second supported rate is used as the second-level rate matching result; Otherwise, if there is a third supporting rate in the list of supported rates that is higher than the optical module's supported rate but less than a set multiple, then the third supporting rate will be used as the third-level rate matching result. Otherwise, the lowest rate in the supported rate list will be used as the fourth-level rate matching result.
4. The method according to claim 1, characterized in that, After performing multi-level rate matching based on the optical module's supported rate to obtain the port's rate matching result, the method further includes: Based on the rate matching results, the configuration information of the port is generated in the database format and reported to the database.
5. The method according to claim 1, characterized in that, The atomic configuration of the port based on its current state and the rate matching result includes: Determine the rollback backup configuration based on the current status of the port; Disable the port and set the port rate according to the rate matching result; Re-enable the port and verify the link status of the link to which the port is located; If the link status remains abnormal for a set period of time, a rollback operation will be performed based on the rollback backup configuration. If the link status is normal, then the port configuration is successful.
6. A port configuration device, characterized in that, include: An information recognition module is used to obtain the optical module's supported rate when an optical module insertion port is detected; A configuration determination module is used to perform multi-level rate matching based on the rate supported by the optical module to obtain the rate matching result of the port; The port configuration module is used to perform atomic configuration on the port based on the current state of the port and the rate matching result.
7. The apparatus according to claim 6, characterized in that, The port configuration module is specifically used for: Determine the rollback backup configuration based on the current status of the port; Disable the port and set the port rate according to the rate matching result; Re-enable the port and verify the link status of the link to which the port is located; If the link status remains abnormal for a set period of time, a rollback operation will be performed based on the rollback backup configuration. If the link status is normal, then the port configuration is successful.
8. An electronic device, characterized in that, The electronic device includes: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the port configuration method according to any one of claims 1-5.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that cause a processor to execute the port configuration method according to any one of claims 1-5.
10. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the port configuration method according to any one of claims 1-5.