目录
代码分析
在ipmbbridged.cpp文件main函数下,我们通过以下代码对函数实现的方法进行进行了注册,该方法的回调函数为 “ipmbHandleRequest”。
conn->request_name(ipmbBus);
auto server = sdbusplus::asio::object_server(conn);
std::shared_ptr<sdbusplus::asio::dbus_interface> ipmbIface =
server.add_interface(ipmbObj, ipmbDbusIntf);
ipmbIface->register_method("sendRequest", std::move(ipmbHandleRequest));
ipmbIface->initialize();
接着,通过initializeChannels函数对模块进行了初始化。该函数是读取/usr/share/ipmbbridge/ipmb-channels.json文件的内容来进行对class IpmbChannel 进行构造。
通过下面代码,可以看到,在/dev/ipmb-N得到新的数据时,将会调用processI2cEvent()函数来进行处理。
i2cSlaveDescriptor.assign(ipmbi2cSlaveFd);
i2cSlaveDescriptor.async_wait(
boost::asio::posix::descriptor_base::wait_read,
[this](const boost::system::error_code &ec) {
if (ec)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"Error: processI2cEvent()");
return;
}
processI2cEvent();
});
通过对processI2cEvent函数的分析,可以看到该函数会对接收到的报文进行各种解析,包括接收到报文字节的长度,报文头是否正确等等。当从机是在向openbmc回复应答报文时,该报文是通过以下case进行返回的。
// copy frame to ipmib message buffer
if (ipmbIsResponse(ipmbFrame))
{
std::unique_ptr<IpmbResponse> ipmbMessageReceived =
std::make_unique<IpmbResponse>();
ipmbMessageReceived->i2cToIpmbConstruct(ipmbFrame, r);
// try to match response with outstanding request
responseMatch(ipmbMessageReceived);
}
如果是其他板卡向openbmc发送报文时,则是通过以下代码。分析该代码可知,在判定netfn与cmd合法之后,报文将送到phoshpor-ipmi-host中对应的函数中进行处理。
// if command is blocked - respond with 'invalid command'
// completion code
if (commandFilter)
{
uint8_

本文档详细介绍了IPMB功能的配置过程,包括设备树配置、menuconfig选项选择以及ipmb-channels.json文件的配置。同时,深入剖析了代码中报文的处理流程,从接收、解析到响应的各个环节,展示了如何处理来自子板的IPMB报文以及向方法调用者返回响应。

3246

被折叠的 条评论
为什么被折叠?



