phosphor-ipmi-ipmb

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

目录

代码分析

配置IPMB功能

 在设备树中配置:

在menuconfig中进行配置   

配置ipmb-channels.json文件


代码分析

在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_
评论 13
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值