blob: a47b9080d0dbd823bdb37107659f78ccc41cc2c4 [file] [log] [blame]
Ratan Guptab8e99552017-07-27 07:07:48 +05301#pragma once
2
Ratan Gupta533d03b2017-07-30 10:39:22 +05303#include "types.hpp"
Patrick Venture0b02be92018-08-31 11:55:55 -07004
Ratan Guptab8e99552017-07-27 07:07:48 +05305#include <string>
Adriana Kobylak5d6481f2015-10-29 21:44:55 -05006// IPMI commands for Transport net functions.
7enum ipmi_netfn_storage_cmds
8{
9 // Get capability bits
10 IPMI_CMD_SET_LAN = 0x01,
11 IPMI_CMD_GET_LAN = 0x02,
12};
13
14// Command specific completion codes
15enum ipmi_transport_return_codes
16{
17 IPMI_CC_PARM_NOT_SUPPORTED = 0x80,
18};
19
Adriana Kobylake08fbc62016-02-09 16:17:23 -060020// Parameters
Patrick Venture0b02be92018-08-31 11:55:55 -070021static const int LAN_PARM_INPROGRESS = 0;
Adriana Kobylake08fbc62016-02-09 16:17:23 -060022static const int LAN_PARM_AUTHSUPPORT = 1;
23static const int LAN_PARM_AUTHENABLES = 2;
Patrick Venture0b02be92018-08-31 11:55:55 -070024static const int LAN_PARM_IP = 3;
25static const int LAN_PARM_IPSRC = 4;
26static const int LAN_PARM_MAC = 5;
27static const int LAN_PARM_SUBNET = 6;
28static const int LAN_PARM_GATEWAY = 12;
29static const int LAN_PARM_VLAN = 20;
30static const int CIPHER_SUITE_COUNT = 22;
Tom Josepha30c8d32018-03-22 02:15:03 +053031static const int CIPHER_SUITE_ENTRIES = 23;
Adriana Kobylake08fbc62016-02-09 16:17:23 -060032
Patrick Venture585a1e92017-11-17 07:36:15 -080033constexpr uint8_t SET_COMPLETE = 0;
34constexpr uint8_t SET_IN_PROGRESS = 1;
Patrick Venture0b02be92018-08-31 11:55:55 -070035constexpr uint8_t SET_COMMIT_WRITE = 2; // Optional
36constexpr uint8_t SET_IN_PROGRESS_RESERVED = 3; // Reserved
Patrick Venture585a1e92017-11-17 07:36:15 -080037
Patrick Venturec7c1c3c2017-11-15 14:29:18 -080038const int CHANNEL_MASK = 0x0f;
39const int NUM_CHANNELS = 0x0f;
40
Ratan Guptab8e99552017-07-27 07:07:48 +053041struct ChannelConfig_t
42{
43 std::string ipaddr;
Ratan Guptacc6cdbf2017-09-01 23:06:25 +053044 ipmi::network::IPOrigin ipsrc = ipmi::network::IPOrigin::UNSPECIFIED;
Ratan Guptab8e99552017-07-27 07:07:48 +053045 std::string netmask;
46 std::string gateway;
47 std::string macAddress;
Ratan Gupta533d03b2017-07-30 10:39:22 +053048 // IPMI stores the vlan info in 16 bits,32 bits is to aligned
49 // with phosphor-dbus interfaces.
50 // vlan id is in 12 bits and the 16th bit is for enable mask.
51 uint32_t vlanID = ipmi::network::VLAN_ID_MASK;
Patrick Venture585a1e92017-11-17 07:36:15 -080052 uint8_t lan_set_in_progress = SET_COMPLETE;
Ratan Gupta7a7f0122018-03-07 12:31:05 +053053 bool flush = false;
Ratan Gupta533d03b2017-07-30 10:39:22 +053054
Ratan Guptab8e99552017-07-27 07:07:48 +053055 void clear()
56 {
57 ipaddr.clear();
58 netmask.clear();
59 gateway.clear();
60 macAddress.clear();
Ratan Gupta533d03b2017-07-30 10:39:22 +053061 vlanID = ipmi::network::VLAN_ID_MASK;
Ratan Guptacc6cdbf2017-09-01 23:06:25 +053062 ipsrc = ipmi::network::IPOrigin::UNSPECIFIED;
Patrick Venture585a1e92017-11-17 07:36:15 -080063 lan_set_in_progress = SET_COMPLETE;
Ratan Gupta7a7f0122018-03-07 12:31:05 +053064 flush = false;
Ratan Guptab8e99552017-07-27 07:07:48 +053065 }
Nan Li3d0df912016-10-18 19:51:41 +080066};
Patrick Venturec7c1c3c2017-11-15 14:29:18 -080067
68// Given a channel, get the corresponding configuration,
69// or allocate it first.
70//
71// @param[in] channel the channel
72// @return the ChannelConfig_t pointer.
73struct ChannelConfig_t* getChannelConfig(int channel);
Ratan Gupta7a7f0122018-03-07 12:31:05 +053074
75/** @brief Iterate over all the channelconfig and if
76 * user has given the data for a channel then
77 * apply the network changes for that channel.
78 */
79void commitNetworkChanges();
80
81/* @brief Apply the network changes which is there in the
82 * network cache for a given channel which gets filled
83 * through setLan command. If some of the network
84 * parameter was not given by the setLan then this function
85 * gets the value of that parameter which is already
86 * configured on the system.
87 * @param[in] channel: channel number.
88 */
89void applyChanges(int channel);