blob: e503fe07f7c4c431602e8025f01b9511ab7f77fc [file] [log] [blame]
Dung Caofaf6a6a2020-12-28 04:44:45 +00001/*
2 * Copyright (c) 2021 Ampere Computing LLC
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 * This is a daemon that forwards requests and receive responses from SSIF over
17 * the D-Bus IPMI Interface.
18 */
19
20#include <getopt.h>
21#include <linux/ipmi_bmc.h>
22
23#include <CLI/CLI.hpp>
24#include <boost/algorithm/string/replace.hpp>
Ed Tanousd289aea2024-02-06 20:33:26 -080025#include <boost/asio/completion_condition.hpp>
26#include <boost/asio/io_context.hpp>
27#include <boost/asio/read.hpp>
28#include <boost/asio/steady_timer.hpp>
29#include <boost/asio/write.hpp>
Dung Caofaf6a6a2020-12-28 04:44:45 +000030#include <phosphor-logging/log.hpp>
31#include <sdbusplus/asio/connection.hpp>
32#include <sdbusplus/asio/object_server.hpp>
Patrick Williams8b050c92023-10-20 11:19:32 -050033#include <sdbusplus/timer.hpp>
Dung Caofaf6a6a2020-12-28 04:44:45 +000034
35#include <iostream>
36
Dung Cao51835392022-10-27 04:29:54 +000037/* Max length of ipmi ssif message included netfn and cmd field */
Ed Tanous7fa7e6c2024-02-14 14:33:32 -080038constexpr const size_t ipmiSsifPayloadMax = 254;
Dung Cao51835392022-10-27 04:29:54 +000039
Ed Tanous498b87f2024-02-14 09:07:34 -080040using phosphor::logging::level;
41using phosphor::logging::log;
Dung Caofaf6a6a2020-12-28 04:44:45 +000042
Ed Tanousa1585be2024-02-14 10:57:31 -080043struct IpmiCmd
Patrick Williams8b050c92023-10-20 11:19:32 -050044{
45 uint8_t netfn;
46 uint8_t lun;
47 uint8_t cmd;
Ed Tanous7fa7e6c2024-02-14 14:33:32 -080048};
quang.ampere14480ee2022-10-18 09:04:51 +070049
Ed Tanous7fa7e6c2024-02-14 14:33:32 -080050static constexpr std::string_view devBase = "/dev/ipmi-ssif-host";
Dung Caofaf6a6a2020-12-28 04:44:45 +000051/* SSIF use IPMI SSIF channel */
Ed Tanousa1585be2024-02-14 10:57:31 -080052
Quang Nguyenf2994dc2022-11-25 16:31:49 +070053/* The timer of driver is set to 15 seconds, need to send
54 * response before timeout occurs
55 */
56static constexpr const unsigned int hostReqTimeout = 14000000;
Dung Caofaf6a6a2020-12-28 04:44:45 +000057
Patrick Williams8b050c92023-10-20 11:19:32 -050058class SsifChannel
59{
60 public:
Patrick Williams7ead0d32024-08-16 15:21:26 -040061 static constexpr size_t ssifMessageSize =
62 ipmiSsifPayloadMax + sizeof(unsigned int);
Patrick Williams8b050c92023-10-20 11:19:32 -050063 size_t sizeofLenField = sizeof(unsigned int);
64 static constexpr uint8_t netFnShift = 2;
65 static constexpr uint8_t lunMask = (1 << netFnShift) - 1;
Dung Caofaf6a6a2020-12-28 04:44:45 +000066
Patrick Williams8b050c92023-10-20 11:19:32 -050067 SsifChannel(std::shared_ptr<boost::asio::io_context>& io,
68 std::shared_ptr<sdbusplus::asio::connection>& bus,
Ed Tanous98f55c72024-02-14 16:23:30 -080069 const std::string& device, bool verbose);
Patrick Williams8b050c92023-10-20 11:19:32 -050070 bool initOK() const
71 {
Ed Tanousfcd0ea42024-02-14 09:15:41 -080072 return dev.is_open();
Patrick Williams8b050c92023-10-20 11:19:32 -050073 }
74 void channelAbort(const char* msg, const boost::system::error_code& ec);
Ed Tanousa1585be2024-02-14 10:57:31 -080075 void asyncRead();
Ed Tanousb6ad9dc2024-02-14 09:28:20 -080076 using IpmiDbusRspType =
77 std::tuple<uint8_t, uint8_t, uint8_t, uint8_t, std::vector<uint8_t>>;
78
79 void afterMethodCall(const boost::system::error_code& ec,
80 const IpmiDbusRspType& response);
Patrick Williams8b050c92023-10-20 11:19:32 -050081 void processMessage(const boost::system::error_code& ecRd, size_t rlen);
Ed Tanousa1585be2024-02-14 10:57:31 -080082 int showNumOfReqNotRsp() const;
Ed Tanousfcd0ea42024-02-14 09:15:41 -080083 boost::asio::posix::stream_descriptor dev;
Ed Tanous7fa7e6c2024-02-14 14:33:32 -080084 IpmiCmd prevReqCmd{};
Dung Caofaf6a6a2020-12-28 04:44:45 +000085
Patrick Williams8b050c92023-10-20 11:19:32 -050086 protected:
Ed Tanousa1585be2024-02-14 10:57:31 -080087 std::array<uint8_t, ssifMessageSize> xferBuffer{};
Patrick Williams8b050c92023-10-20 11:19:32 -050088 std::shared_ptr<boost::asio::io_context> io;
89 std::shared_ptr<sdbusplus::asio::connection> bus;
90 std::shared_ptr<sdbusplus::asio::object_server> server;
91 bool verbose;
Thang Q. Nguyenbaabadf2024-06-24 08:56:09 +070092 /* This variable is always 0 when a request is responded properly,
Patrick Williams8b050c92023-10-20 11:19:32 -050093 * any value larger than 0 meaning there is/are request(s) which
94 * not processed properly
95 * */
Ed Tanous98f55c72024-02-14 16:23:30 -080096 int numberOfReqNotRsp = 0;
Ed Tanous4ae3b9e2024-02-14 08:54:03 -080097
98 boost::asio::steady_timer rspTimer;
Dung Caofaf6a6a2020-12-28 04:44:45 +000099};
100
Ed Tanous7fa7e6c2024-02-14 14:33:32 -0800101// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
Quang Nguyenf2994dc2022-11-25 16:31:49 +0700102std::unique_ptr<SsifChannel> ssifchannel = nullptr;
103
Patrick Williams8b050c92023-10-20 11:19:32 -0500104SsifChannel::SsifChannel(std::shared_ptr<boost::asio::io_context>& io,
105 std::shared_ptr<sdbusplus::asio::connection>& bus,
Ed Tanous98f55c72024-02-14 16:23:30 -0800106 const std::string& device, bool verbose) :
Patrick Williams7ead0d32024-08-16 15:21:26 -0400107 dev(*io), io(io), bus(bus), verbose(verbose), rspTimer(*io)
Dung Caofaf6a6a2020-12-28 04:44:45 +0000108{
Ed Tanous7fa7e6c2024-02-14 14:33:32 -0800109 std::string devName(devBase);
Patrick Williams8b050c92023-10-20 11:19:32 -0500110 if (!device.empty())
111 {
112 devName = device;
113 }
Dung Caofaf6a6a2020-12-28 04:44:45 +0000114
Patrick Williams8b050c92023-10-20 11:19:32 -0500115 // open device
Ed Tanous7fa7e6c2024-02-14 14:33:32 -0800116 // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
Patrick Williams8b050c92023-10-20 11:19:32 -0500117 int fd = open(devName.c_str(), O_RDWR | O_NONBLOCK);
118 if (fd < 0)
119 {
120 std::string msgToLog = "Couldn't open SSIF driver with flags O_RDWR."
121 " FILENAME=" +
122 devName + " ERROR=" + strerror(errno);
123 log<level::ERR>(msgToLog.c_str());
124 return;
125 }
Dung Caofaf6a6a2020-12-28 04:44:45 +0000126
Ed Tanousa1585be2024-02-14 10:57:31 -0800127 dev.assign(fd);
128
129 asyncRead();
Patrick Williams8b050c92023-10-20 11:19:32 -0500130 // register interfaces...
131 server = std::make_shared<sdbusplus::asio::object_server>(bus);
132 std::shared_ptr<sdbusplus::asio::dbus_interface> iface =
Ed Tanousa1585be2024-02-14 10:57:31 -0800133 server->add_interface("/xyz/openbmc_project/Ipmi/Channel/ipmi_ssif",
Ed Tanous7fa7e6c2024-02-14 14:33:32 -0800134 "xyz.openbmc_project.Ipmi.Channel.ipmi_ssif");
Patrick Williams8b050c92023-10-20 11:19:32 -0500135 iface->initialize();
Dung Caofaf6a6a2020-12-28 04:44:45 +0000136}
137
Patrick Williams8b050c92023-10-20 11:19:32 -0500138void SsifChannel::channelAbort(const char* msg,
139 const boost::system::error_code& ec)
Dung Caofaf6a6a2020-12-28 04:44:45 +0000140{
Patrick Williams8b050c92023-10-20 11:19:32 -0500141 std::string msgToLog = std::string(msg) + " ERROR=" + ec.message();
142 log<level::ERR>(msgToLog.c_str());
143 // bail; maybe a restart from systemd can clear the error
144 io->stop();
Dung Caofaf6a6a2020-12-28 04:44:45 +0000145}
146
Ed Tanousa1585be2024-02-14 10:57:31 -0800147void SsifChannel::asyncRead()
Dung Caofaf6a6a2020-12-28 04:44:45 +0000148{
Patrick Williams7ead0d32024-08-16 15:21:26 -0400149 boost::asio::async_read(
150 dev, boost::asio::buffer(xferBuffer, xferBuffer.size()),
151 boost::asio::transfer_at_least(2),
152 [this](const boost::system::error_code& ec, size_t rlen) {
153 processMessage(ec, rlen);
154 });
Dung Caofaf6a6a2020-12-28 04:44:45 +0000155}
156
Ed Tanousa1585be2024-02-14 10:57:31 -0800157int SsifChannel::showNumOfReqNotRsp() const
Quang Nguyenf2994dc2022-11-25 16:31:49 +0700158{
Patrick Williams8b050c92023-10-20 11:19:32 -0500159 return numberOfReqNotRsp;
Quang Nguyenf2994dc2022-11-25 16:31:49 +0700160}
161
Ed Tanousd289aea2024-02-06 20:33:26 -0800162void rspTimerHandler(const boost::system::error_code& ec)
Quang Nguyenf2994dc2022-11-25 16:31:49 +0700163{
Ed Tanousd289aea2024-02-06 20:33:26 -0800164 if (ec == boost::asio::error::operation_aborted)
165 {
166 return;
167 }
Patrick Williams8b050c92023-10-20 11:19:32 -0500168 std::vector<uint8_t> rsp;
169 constexpr uint8_t ccResponseNotAvailable = 0xce;
Ed Tanous7fa7e6c2024-02-14 14:33:32 -0800170 IpmiCmd& prevReqCmd = ssifchannel->prevReqCmd;
Ed Tanousa1585be2024-02-14 10:57:31 -0800171 rsp.resize(ssifchannel->sizeofLenField + sizeof(prevReqCmd.cmd) +
172 sizeof(prevReqCmd.netfn) + sizeof(ccResponseNotAvailable));
Patrick Williams7ead0d32024-08-16 15:21:26 -0400173 std::string msgToLog =
174 "timeout, send response to keep host alive"
175 " netfn=" +
176 std::to_string(prevReqCmd.netfn) +
177 " lun=" + std::to_string(prevReqCmd.lun) +
178 " cmd=" + std::to_string(prevReqCmd.cmd) +
179 " cc=" + std::to_string(ccResponseNotAvailable) +
180 " numberOfReqNotRsp=" +
181 std::to_string(ssifchannel->showNumOfReqNotRsp());
Patrick Williams8b050c92023-10-20 11:19:32 -0500182 log<level::INFO>(msgToLog.c_str());
Ed Tanous7fa7e6c2024-02-14 14:33:32 -0800183 // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
184 unsigned int* t = reinterpret_cast<unsigned int*>(rsp.data());
Patrick Williams8b050c92023-10-20 11:19:32 -0500185 *t = 3;
Patrick Williams7ead0d32024-08-16 15:21:26 -0400186 rsp[ssifchannel->sizeofLenField] =
187 ((prevReqCmd.netfn + 1) << ssifchannel->netFnShift) |
188 (prevReqCmd.lun & ssifchannel->lunMask);
Ed Tanousa1585be2024-02-14 10:57:31 -0800189 rsp[ssifchannel->sizeofLenField + 1] = prevReqCmd.cmd;
Patrick Williams8b050c92023-10-20 11:19:32 -0500190 rsp[ssifchannel->sizeofLenField + 2] = ccResponseNotAvailable;
Quang Nguyenf2994dc2022-11-25 16:31:49 +0700191
Patrick Williams8b050c92023-10-20 11:19:32 -0500192 boost::system::error_code ecWr;
Quang Nguyenf2994dc2022-11-25 16:31:49 +0700193
Patrick Williams7ead0d32024-08-16 15:21:26 -0400194 size_t wlen =
195 boost::asio::write(ssifchannel->dev, boost::asio::buffer(rsp), ecWr);
Patrick Williams8b050c92023-10-20 11:19:32 -0500196 if (ecWr || wlen != rsp.size())
197 {
198 msgToLog =
199 "Failed to send ssif respond message:"
200 " size=" +
201 std::to_string(wlen) + " expect=" + std::to_string(rsp.size()) +
202 " error=" + ecWr.message() +
Ed Tanousa1585be2024-02-14 10:57:31 -0800203 " netfn=" + std::to_string(prevReqCmd.netfn + 1) +
204 " lun=" + std::to_string(prevReqCmd.lun) +
Patrick Williams8b050c92023-10-20 11:19:32 -0500205 " cmd=" + std::to_string(rsp[ssifchannel->sizeofLenField + 1]) +
206 " cc=" + std::to_string(ccResponseNotAvailable);
207 log<level::ERR>(msgToLog.c_str());
208 }
Quang Nguyenf2994dc2022-11-25 16:31:49 +0700209}
210
Ed Tanousb6ad9dc2024-02-14 09:28:20 -0800211void SsifChannel::afterMethodCall(const boost::system::error_code& ec,
212 const IpmiDbusRspType& response)
213{
214 std::vector<uint8_t> rsp;
215 const auto& [netfn, lun, cmd, cc, payload] = response;
216 numberOfReqNotRsp--;
217 if (ec)
218 {
219 std::string msgToLog =
220 "ssif<->ipmid bus error:"
221 " netfn=" +
222 std::to_string(netfn) + " lun=" + std::to_string(lun) +
223 " cmd=" + std::to_string(cmd) + " error=" + ec.message();
224 log<level::ERR>(msgToLog.c_str());
225 rsp.resize(sizeofLenField + sizeof(netfn) + sizeof(cmd) + sizeof(cc));
226 /* if dbusTimeout, just return and do not send any response
227 * to let host continue with other commands, response here
228 * is potentially make the response duplicated
229 * */
230 return;
231 }
Ed Tanousb6ad9dc2024-02-14 09:28:20 -0800232
Ed Tanous7fa7e6c2024-02-14 14:33:32 -0800233 if ((prevReqCmd.netfn != (netfn - 1) || prevReqCmd.lun != lun ||
234 prevReqCmd.cmd != cmd) ||
235 ((prevReqCmd.netfn == (netfn - 1) && prevReqCmd.lun == lun &&
236 prevReqCmd.cmd == cmd) &&
237 numberOfReqNotRsp != 0))
238 {
239 /* Only send response to the last request command to void
240 * duplicated response which makes host driver confused and
241 * failed to create interface
242 *
243 * Drop responses which are (1) different from the request
244 * (2) parameters are the same as request but handshake flow
Thang Q. Nguyenbaabadf2024-06-24 08:56:09 +0700245 * are in duplicated request state
Ed Tanous7fa7e6c2024-02-14 14:33:32 -0800246 * */
247 if (verbose)
Ed Tanousb6ad9dc2024-02-14 09:28:20 -0800248 {
Ed Tanous7fa7e6c2024-02-14 14:33:32 -0800249 std::string msgToLog =
250 "Drop ssif respond message with"
251 " len=" +
252 std::to_string(payload.size() + 3) +
253 " netfn=" + std::to_string(netfn) +
254 " lun=" + std::to_string(lun) + " cmd=" + std::to_string(cmd) +
255 " cc=" + std::to_string(cc) +
256 " numberOfReqNotRsp=" + std::to_string(numberOfReqNotRsp);
257 log<level::INFO>(msgToLog.c_str());
Ed Tanousb6ad9dc2024-02-14 09:28:20 -0800258 }
Ed Tanous7fa7e6c2024-02-14 14:33:32 -0800259 return;
260 }
261 rsp.resize(sizeofLenField + sizeof(netfn) + sizeof(cmd) + sizeof(cc) +
262 payload.size());
263
264 // write the response
265 auto rspIter = rsp.begin();
266 // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
267 unsigned int* p = reinterpret_cast<unsigned int*>(&rspIter[0]);
268 *p = payload.size() + 3;
269 rspIter[sizeofLenField] = (netfn << netFnShift) | (lun & lunMask);
270 rspIter[sizeofLenField + 1] = cmd;
271 rspIter[sizeofLenField + 2] = cc;
272 if (static_cast<unsigned int>(!payload.empty()) != 0U)
273 {
274 std::copy(payload.cbegin(), payload.cend(),
275 rspIter + sizeofLenField + 3);
Ed Tanousb6ad9dc2024-02-14 09:28:20 -0800276 }
277 if (verbose)
278 {
279 std::string msgToLog =
280 "Send ssif respond message with"
281 " len=" +
282 std::to_string(payload.size() + 3) +
283 " netfn=" + std::to_string(netfn) + " lun=" + std::to_string(lun) +
284 " cmd=" + std::to_string(cmd) + " cc=" + std::to_string(cc) +
285 " numberOfReqNotRsp=" + std::to_string(numberOfReqNotRsp);
286 log<level::INFO>(msgToLog.c_str());
287 }
288 boost::system::error_code ecWr;
289 size_t wlen = boost::asio::write(dev, boost::asio::buffer(rsp), ecWr);
290 if (ecWr || wlen != rsp.size())
291 {
292 std::string msgToLog =
293 "Failed to send ssif respond message:"
294 " size=" +
295 std::to_string(wlen) + " expect=" + std::to_string(rsp.size()) +
296 " error=" + ecWr.message() + " netfn=" + std::to_string(netfn) +
297 " lun=" + std::to_string(lun) + " cmd=" + std::to_string(cmd) +
298 " cc=" + std::to_string(cc);
299 log<level::ERR>(msgToLog.c_str());
300 }
301 rspTimer.cancel();
302}
303
Patrick Williams8b050c92023-10-20 11:19:32 -0500304void SsifChannel::processMessage(const boost::system::error_code& ecRd,
305 size_t rlen)
Dung Caofaf6a6a2020-12-28 04:44:45 +0000306{
Patrick Williams8b050c92023-10-20 11:19:32 -0500307 if (ecRd || rlen < 2)
308 {
309 channelAbort("Failed to read req msg", ecRd);
310 return;
311 }
Ed Tanousa1585be2024-02-14 10:57:31 -0800312 asyncRead();
Dung Caofaf6a6a2020-12-28 04:44:45 +0000313
Ed Tanousa1585be2024-02-14 10:57:31 -0800314 const auto* rawIter = xferBuffer.cbegin();
315 const auto* rawEnd = rawIter + rlen;
Patrick Williams8b050c92023-10-20 11:19:32 -0500316 uint8_t netfn = rawIter[sizeofLenField] >> netFnShift;
317 uint8_t lun = rawIter[sizeofLenField] & lunMask;
318 uint8_t cmd = rawIter[sizeofLenField + 1];
quang.ampere14480ee2022-10-18 09:04:51 +0700319
Patrick Williams8b050c92023-10-20 11:19:32 -0500320 /* keep track of previous request */
Ed Tanousa1585be2024-02-14 10:57:31 -0800321 prevReqCmd.netfn = netfn;
322 prevReqCmd.lun = lun;
323 prevReqCmd.cmd = cmd;
quang.ampere14480ee2022-10-18 09:04:51 +0700324
Patrick Williams8b050c92023-10-20 11:19:32 -0500325 /* there is a request coming */
326 numberOfReqNotRsp++;
327 /* start response timer */
Ed Tanous4ae3b9e2024-02-14 08:54:03 -0800328 rspTimer.expires_after(std::chrono::microseconds(hostReqTimeout));
329 rspTimer.async_wait(rspTimerHandler);
quang.name507782a2022-11-20 17:05:20 +0700330
Patrick Williams8b050c92023-10-20 11:19:32 -0500331 if (verbose)
332 {
Ed Tanousa1585be2024-02-14 10:57:31 -0800333 unsigned int lenRecv = 0;
Ed Tanous7fa7e6c2024-02-14 14:33:32 -0800334 // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
335 const unsigned int* p = reinterpret_cast<const unsigned int*>(rawIter);
Patrick Williams8b050c92023-10-20 11:19:32 -0500336 lenRecv = p[0];
337 std::string msgToLog =
338 "Read ssif request message with"
339 " len=" +
340 std::to_string(lenRecv) + " netfn=" + std::to_string(netfn) +
341 " lun=" + std::to_string(lun) + " cmd=" + std::to_string(cmd) +
342 " numberOfReqNotRsp=" + std::to_string(numberOfReqNotRsp);
343 log<level::INFO>(msgToLog.c_str());
344 }
345 // copy out payload
346 std::vector<uint8_t> data(rawIter + sizeofLenField + 2, rawEnd);
347 // non-session bridges still need to pass an empty options map
348 std::map<std::string, std::variant<int>> options;
Ed Tanous7fa7e6c2024-02-14 14:33:32 -0800349 static constexpr const char* ipmiQueueService =
Patrick Williams8b050c92023-10-20 11:19:32 -0500350 "xyz.openbmc_project.Ipmi.Host";
Ed Tanous7fa7e6c2024-02-14 14:33:32 -0800351 static constexpr const char* ipmiQueuePath = "/xyz/openbmc_project/Ipmi";
352 static constexpr const char* ipmiQueueIntf =
Patrick Williams8b050c92023-10-20 11:19:32 -0500353 "xyz.openbmc_project.Ipmi.Server";
Ed Tanous7fa7e6c2024-02-14 14:33:32 -0800354 static constexpr const char* ipmiQueueMethod = "execute";
Patrick Williams8b050c92023-10-20 11:19:32 -0500355 /* now, we do not care dbus timeout, since we already have actions
356 * before dbus timeout occurs
357 */
358 static constexpr unsigned int dbusTimeout = 60000000;
359 bus->async_method_call_timed(
Ed Tanousb6ad9dc2024-02-14 09:28:20 -0800360 [this](const boost::system::error_code& ec,
361 const IpmiDbusRspType& response) {
Patrick Williams7ead0d32024-08-16 15:21:26 -0400362 afterMethodCall(ec, response);
363 },
Patrick Williams8b050c92023-10-20 11:19:32 -0500364 ipmiQueueService, ipmiQueuePath, ipmiQueueIntf, ipmiQueueMethod,
365 dbusTimeout, netfn, lun, cmd, data, options);
Dung Caofaf6a6a2020-12-28 04:44:45 +0000366}
367
Patrick Williams8b050c92023-10-20 11:19:32 -0500368int main(int argc, char* argv[])
Dung Caofaf6a6a2020-12-28 04:44:45 +0000369{
Patrick Williams8b050c92023-10-20 11:19:32 -0500370 CLI::App app("SSIF IPMI bridge");
371 std::string device;
372 app.add_option("-d,--device", device,
373 "use <DEVICE> file. Default is /dev/ipmi-ssif-host");
374 bool verbose = false;
Patrick Williams8b050c92023-10-20 11:19:32 -0500375 app.add_option("-v,--verbose", verbose, "print more verbose output");
376 CLI11_PARSE(app, argc, argv);
Dung Caofaf6a6a2020-12-28 04:44:45 +0000377
Patrick Williams8b050c92023-10-20 11:19:32 -0500378 auto io = std::make_shared<boost::asio::io_context>();
Dung Caofaf6a6a2020-12-28 04:44:45 +0000379
Ed Tanousd289aea2024-02-06 20:33:26 -0800380 auto bus = std::make_shared<sdbusplus::asio::connection>(*io);
Ed Tanous7fa7e6c2024-02-14 14:33:32 -0800381 bus->request_name("xyz.openbmc_project.Ipmi.Channel.ipmi_ssif");
Patrick Williams8b050c92023-10-20 11:19:32 -0500382 // Create the SSIF channel, listening on D-Bus and on the SSIF device
Ed Tanous98f55c72024-02-14 16:23:30 -0800383 ssifchannel = make_unique<SsifChannel>(io, bus, device, verbose);
Patrick Williams8b050c92023-10-20 11:19:32 -0500384 if (!ssifchannel->initOK())
385 {
386 return EXIT_FAILURE;
387 }
Patrick Williams8b050c92023-10-20 11:19:32 -0500388 io->run();
Thang Q. Nguyen4300d212023-05-15 12:22:53 +0700389
Patrick Williams8b050c92023-10-20 11:19:32 -0500390 return 0;
Dung Caofaf6a6a2020-12-28 04:44:45 +0000391}