Network Port Connection Status Handbook
更新时间: 2025/10/15
在Gitcode上查看源码

Network Port Connection Status Handbook

1. Types of Network Port Connection Statuses

For details, see the online help. The statuses are as follows:

  • --: The iBMA is not installed on the server, and the physical connection status cannot be obtained.
  • Connected: The iBMA is not installed on the server, and the physical link is connected.
  • Disconnected: The iBMA is not installed on the server, and the physical link is not connected.
  • NoLink: The iBMA has been installed on the server, the port is not connected, but the port status is Up.
  • LinkUp: The iBMA has been installed on the server, the port is connected, and the port status is Up.
  • LinkDown: The iBMA has been installed on the server, and the port status is Down.

The connection status is closely related to whether the iBMA is installed, whether the port is cabled, and whether the port is up. The following sections describe the details.

1.1 How to Determine if iBMA is Installed

1.1.1 Querying via the Resource Tree

TODO: Fill in the definition of the Registered method for bmc.kepler.Systems.Sms here.

Run the busctl command to query:

bash
busctl --user introspect bmc.kepler.host_agent /bmc/kepler/Systems/1/Sms

The following figure shows that the iBMA is not installed.

1.1.2 Querying via the BMC Web Page

Currently, the iBMA has a separate tab page on the WebUI.

After navigating to the details tab page, you can see whether the iBMA is installed.

1.1.3 In-Band Querying

Use the service BMA status command.

The following figure shows that the iBMA is not installed.

The following figure shows that the iBMA is installed and running properly.

The following figure shows that the iBMA is installed but not running.

1.2 How to Determine if a Port is Cabled

1.2.1 Using the ethtool Command In-Band

Run ifconfig to view network ports.

Run ethtool to view the cabling status of a specific network port.

The following figure shows that it is cabled.

The following figure shows that it is not cabled.

1.3 How to Determine if a Port Status is Up or Down

Use the ifconfig command to view or modify.

As shown in the following figure, the eno2 network port is up.

After the ifconfig eno2 down command is executed, if the status lacks <UP,...>, the eno2 network port is down.

2. Obtaining Network Port Connection Statuses

The following methods have been implemented in openUBMC.

2.1 Obtaining Status from CPLD via SMC Command Words

2.1.1 Code Implementation

This method applies only to onboard NICs.

You can configure scanners in the NIC CSR file using SMC command words.

Network port properties are associated with a scanner. Select LOM1 or LOM2 via the slot number.

Initial assignment and listening for property changes:

LinkStatusNumeric is an unsigned 8-bit integer, and LinkStatus is a string. Conversion is required.

In the network_port.lua file, the register_property_changed_callback() function is called once during initialization. At this point, LinkStatusNumeric is converted to the required string for the first time.

This function also registers a listener. When LinkStatusNumeric changes, LinkStatus is updated synchronously.

2.1.2 Querying in a Real Environment

Run the busctl command to query:

bash
busctl --user call bmc.kepler.hwproxy /bmc/kepler/Chip/Smc/Smc_ExpBoardSMC_010101 bmc.kepler.Chip.BlockIO Read a{ss}uu 0 0x1c002d00 2
  • The first byte (bits 0, 1, 2, and 3) corresponds to the connection statuses of network ports 1, 2, 3, and 4 of NIC 1.
  • The second byte (bits 0, 1, 2, and 3) corresponds to the connection statuses of network ports 1, 2, 3, and 4 of NIC 2.

Based on the command word results, as shown in the figure, only network port 1 of NIC 2 is connected, and the other network ports are disconnected.

2.2 Obtaining Status from NIC Out-of-Band via SMBus

2.2.1 Code Implementation

Configure Chip in the CSR and associate NIC properties.

Write the configuration file for the corresponding NIC model.

The followings figure shows the configuration file directory.

Configure the Model property of the NIC.

Load the configuration file:

The code constructs the configuration file name based on the Model property and executes the require function.

Implement the connection status command word in the configuration file.

Field description:

  • protocol: protocol type. For example, set it to smbus for SMBus. Protocols are summarized in libmgmt_protocol.
  • action: whether to obtain data periodically. on_schedule represents periodic acquisition, and on_demand represents non-periodic, single-time acquisition.
  • period_in_sec: periodic polling interval, in seconds. This field needs to be configured only when action is set to on_schedule.
  • request: request input parameters. The figure shows an opcode. The code can also pass extra parameters like channelid.
  • response: results returned to the application. You can write functions to perform simple processing on the raw response data for easier use by the application.

Note: For details, see libmgmt_protocol.

The configuration file returns SMBus.

The application initializes SMBus.

When the network_adapter.lua file is initialized, the protocol is initialized via the init_protocol() function.

Prerequisites: The configuration file returns SMBus, the NIC is associated with a corresponding chip, and the chip is readable and writable.

During SMBus initialization, the device_spec_parser interface provided by libmgmt_protocol is called to create an accessible object, which is then assigned to the smbus_config_obj property.

device_spec_parser source code is as follows.

Use the results in application code.

The application code only needs to call LinkStatus implemented in the configuration file to obtain the network port connection status.

When properties are obtained through polling, libmgmt_protocol provides property change signals and error signals for the application to perform post-processing.

As shown in the preceding figure, table_compare() is used to compare two responses. If there is a difference, the emit_signal_on_data_change function sends an on_data_change signal. The application listens for the signal and performs property assignment.

(The following example is captured from other code and is unrelated to LinkStatus)

If no response is obtained, the emit_signal_on_error function sends an on_error signal. The application listens for the signal and performs exception handling.

(The following example is captured from other code and is unrelated to LinkStatus)

2.2.2 Querying in a Real Environment

Set the log level of network_adapter to debug:

bash
busctl --user call bmc.kepler.network_adapter /bmc/kepler/network_adapter/MicroComponent bmc.kepler.MicroComponent.Debug SetDlogLevel a{ss}sy 0 "debug" 100

View real-time SMBus messages:

bash
tail -f /var/log/app.log | grep network_adapter

Filter messages by opcode.