blob: 0a247bdcfc4fdf0a6788f6ece21f485ba516edae [file] [log] [blame]
Dung Cao956cbfc2021-06-11 09:24:57 +00001/*
2 * Copyright (c) 2018-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#pragma once
17#include <ipmid/api.hpp>
18#include <sdbusplus/message.hpp>
19#include <sdbusplus/server/interface.hpp>
20
21struct IpmbResponse
22{
23 uint8_t address;
24 uint8_t netFn;
25 uint8_t rqLun;
26 uint8_t rsSA;
27 uint8_t seq;
28 uint8_t rsLun;
29 uint8_t cmd;
30 uint8_t completionCode;
31 std::vector<uint8_t> data;
32
33 IpmbResponse(uint8_t address, uint8_t netFn, uint8_t rqLun, uint8_t rsSA,
34 uint8_t seq, uint8_t rsLun, uint8_t cmd,
35 uint8_t completionCode, std::vector<uint8_t>& inputData);
36
37 void ipmbToi2cConstruct(uint8_t* buffer, size_t* bufferLength);
38};
39
40/** @class Bridging
41 *
42 * @brief Implement commands to support IPMI bridging.
43 */
44class Bridging
45{
46 public:
47 Bridging() = default;
48 std::size_t getResponseQueueSize();
49
50 void clearResponseQueue();
51 void insertMessageInQueue(IpmbResponse msg);
52 IpmbResponse getMessageFromQueue();
53 void eraseMessageFromQueue();
54
55 private:
56 std::vector<IpmbResponse> responseQueue;
57};