blob: 12b10c96ce78d7281d608ea873158513b273f9b7 [file] [log] [blame]
AppaRao Puli071f3f22018-05-24 16:45:30 +05301/*
2// Copyright (c) 2018 Intel Corporation
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
17#include "channel_layer.hpp"
18
19#include "channel_mgmt.hpp"
20
21#include <phosphor-logging/log.hpp>
22
23namespace ipmi
24{
25
Richard Marian Thomaiyara45cb342018-12-03 15:08:59 +053026bool doesDeviceExist(const uint8_t chNum)
AppaRao Puli071f3f22018-05-24 16:45:30 +053027{
28 // TODO: This is not the reliable way to find the device
29 // associated with ethernet interface as the channel number to
30 // eth association is not done. Need to revisit later
Richard Marian Thomaiyar73906b92019-01-04 23:48:02 +053031 struct stat fileStat = {0};
32 std::string devName("/sys/class/net/" +
33 getChannelConfigObject().getChannelName(chNum));
AppaRao Puli071f3f22018-05-24 16:45:30 +053034
35 if (stat(devName.data(), &fileStat) != 0)
36 {
37 phosphor::logging::log<phosphor::logging::level::DEBUG>(
38 "Ethernet device not found");
39 return false;
40 }
41
42 return true;
43}
44
Richard Marian Thomaiyara45cb342018-12-03 15:08:59 +053045bool isValidPrivLimit(const uint8_t privLimit)
AppaRao Puli071f3f22018-05-24 16:45:30 +053046{
47 return ((privLimit >= PRIVILEGE_CALLBACK) && (privLimit <= PRIVILEGE_OEM));
48}
49
Richard Marian Thomaiyara45cb342018-12-03 15:08:59 +053050bool isValidAccessMode(const uint8_t accessMode)
AppaRao Puli071f3f22018-05-24 16:45:30 +053051{
52 return (
53 (accessMode >= static_cast<uint8_t>(EChannelAccessMode::disabled)) &&
54 (accessMode <= static_cast<uint8_t>(EChannelAccessMode::shared)));
55}
56
Richard Marian Thomaiyara45cb342018-12-03 15:08:59 +053057bool isValidChannel(const uint8_t chNum)
AppaRao Puli071f3f22018-05-24 16:45:30 +053058{
59 return getChannelConfigObject().isValidChannel(chNum);
60}
61
Richard Marian Thomaiyara39208e2018-12-08 17:27:11 +053062uint8_t convertCurrentChannelNum(const uint8_t chNum)
63{
64 return getChannelConfigObject().convertToChannelIndexNumber(chNum);
65}
66
Richard Marian Thomaiyara45cb342018-12-03 15:08:59 +053067bool isValidAuthType(const uint8_t chNum, const EAuthType& authType)
AppaRao Puli071f3f22018-05-24 16:45:30 +053068{
69 return getChannelConfigObject().isValidAuthType(chNum, authType);
70}
71
Richard Marian Thomaiyara45cb342018-12-03 15:08:59 +053072EChannelSessSupported getChannelSessionSupport(const uint8_t chNum)
AppaRao Puli071f3f22018-05-24 16:45:30 +053073{
74 return getChannelConfigObject().getChannelSessionSupport(chNum);
75}
76
Richard Marian Thomaiyara45cb342018-12-03 15:08:59 +053077int getChannelActiveSessions(const uint8_t chNum)
AppaRao Puli071f3f22018-05-24 16:45:30 +053078{
79 return getChannelConfigObject().getChannelActiveSessions(chNum);
80}
81
Vernon Mauery58317122018-11-28 11:02:43 -080082size_t getChannelMaxTransferSize(uint8_t chNum)
83{
84 return getChannelConfigObject().getChannelMaxTransferSize(chNum);
85}
86
AppaRao Puli071f3f22018-05-24 16:45:30 +053087ipmi_ret_t ipmiChannelInit()
88{
89 getChannelConfigObject();
90 return IPMI_CC_OK;
91}
92
Richard Marian Thomaiyara45cb342018-12-03 15:08:59 +053093ipmi_ret_t getChannelInfo(const uint8_t chNum, ChannelInfo& chInfo)
AppaRao Puli071f3f22018-05-24 16:45:30 +053094{
95 return getChannelConfigObject().getChannelInfo(chNum, chInfo);
96}
97
Richard Marian Thomaiyara45cb342018-12-03 15:08:59 +053098ipmi_ret_t getChannelAccessData(const uint8_t chNum,
AppaRao Puli071f3f22018-05-24 16:45:30 +053099 ChannelAccess& chAccessData)
100{
101 return getChannelConfigObject().getChannelAccessData(chNum, chAccessData);
102}
103
Richard Marian Thomaiyara45cb342018-12-03 15:08:59 +0530104ipmi_ret_t setChannelAccessData(const uint8_t chNum,
AppaRao Puli071f3f22018-05-24 16:45:30 +0530105 const ChannelAccess& chAccessData,
Richard Marian Thomaiyara45cb342018-12-03 15:08:59 +0530106 const uint8_t setFlag)
AppaRao Puli071f3f22018-05-24 16:45:30 +0530107{
108 return getChannelConfigObject().setChannelAccessData(chNum, chAccessData,
109 setFlag);
110}
111
Richard Marian Thomaiyara45cb342018-12-03 15:08:59 +0530112ipmi_ret_t getChannelAccessPersistData(const uint8_t chNum,
AppaRao Puli071f3f22018-05-24 16:45:30 +0530113 ChannelAccess& chAccessData)
114{
115 return getChannelConfigObject().getChannelAccessPersistData(chNum,
116 chAccessData);
117}
118
Richard Marian Thomaiyara45cb342018-12-03 15:08:59 +0530119ipmi_ret_t setChannelAccessPersistData(const uint8_t chNum,
AppaRao Puli071f3f22018-05-24 16:45:30 +0530120 const ChannelAccess& chAccessData,
Richard Marian Thomaiyara45cb342018-12-03 15:08:59 +0530121 const uint8_t setFlag)
AppaRao Puli071f3f22018-05-24 16:45:30 +0530122{
123 return getChannelConfigObject().setChannelAccessPersistData(
124 chNum, chAccessData, setFlag);
125}
126
Richard Marian Thomaiyara45cb342018-12-03 15:08:59 +0530127ipmi_ret_t getChannelAuthTypeSupported(const uint8_t chNum,
AppaRao Puli071f3f22018-05-24 16:45:30 +0530128 uint8_t& authTypeSupported)
129{
130 return getChannelConfigObject().getChannelAuthTypeSupported(
131 chNum, authTypeSupported);
132}
133
Richard Marian Thomaiyara45cb342018-12-03 15:08:59 +0530134ipmi_ret_t getChannelEnabledAuthType(const uint8_t chNum, const uint8_t priv,
AppaRao Puli071f3f22018-05-24 16:45:30 +0530135 EAuthType& authType)
136{
137 return getChannelConfigObject().getChannelEnabledAuthType(chNum, priv,
138 authType);
139}
140
141} // namespace ipmi