blob: f27355f6fd5ba0f0485a0b37b6cb7ac14ac1ad75 [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
William A. Kennington IIIaab20232018-11-19 18:20:39 -080021enum class LanParam : uint8_t
William A. Kennington III7a3479e2018-11-19 17:41:20 -080022{
William A. Kennington IIIaab20232018-11-19 18:20:39 -080023 INPROGRESS = 0,
24 AUTHSUPPORT = 1,
25 AUTHENABLES = 2,
26 IP = 3,
27 IPSRC = 4,
28 MAC = 5,
29 SUBNET = 6,
30 GATEWAY = 12,
31 VLAN = 20,
William A. Kennington III7a3479e2018-11-19 17:41:20 -080032 CIPHER_SUITE_COUNT = 22,
33 CIPHER_SUITE_ENTRIES = 23,
34};
Adriana Kobylake08fbc62016-02-09 16:17:23 -060035
Patrick Venture585a1e92017-11-17 07:36:15 -080036constexpr uint8_t SET_COMPLETE = 0;
37constexpr uint8_t SET_IN_PROGRESS = 1;
Patrick Venture0b02be92018-08-31 11:55:55 -070038constexpr uint8_t SET_COMMIT_WRITE = 2; // Optional
39constexpr uint8_t SET_IN_PROGRESS_RESERVED = 3; // Reserved
Patrick Venture585a1e92017-11-17 07:36:15 -080040
Patrick Venturec7c1c3c2017-11-15 14:29:18 -080041const int CHANNEL_MASK = 0x0f;
42const int NUM_CHANNELS = 0x0f;
43
Ratan Guptab8e99552017-07-27 07:07:48 +053044struct ChannelConfig_t
45{
46 std::string ipaddr;
Ratan Guptacc6cdbf2017-09-01 23:06:25 +053047 ipmi::network::IPOrigin ipsrc = ipmi::network::IPOrigin::UNSPECIFIED;
Ratan Guptab8e99552017-07-27 07:07:48 +053048 std::string netmask;
49 std::string gateway;
50 std::string macAddress;
Ratan Gupta533d03b2017-07-30 10:39:22 +053051 // IPMI stores the vlan info in 16 bits,32 bits is to aligned
52 // with phosphor-dbus interfaces.
53 // vlan id is in 12 bits and the 16th bit is for enable mask.
54 uint32_t vlanID = ipmi::network::VLAN_ID_MASK;
Patrick Venture585a1e92017-11-17 07:36:15 -080055 uint8_t lan_set_in_progress = SET_COMPLETE;
Ratan Gupta7a7f0122018-03-07 12:31:05 +053056 bool flush = false;
Ratan Gupta533d03b2017-07-30 10:39:22 +053057
Ratan Guptab8e99552017-07-27 07:07:48 +053058 void clear()
59 {
60 ipaddr.clear();
61 netmask.clear();
62 gateway.clear();
63 macAddress.clear();
Ratan Gupta533d03b2017-07-30 10:39:22 +053064 vlanID = ipmi::network::VLAN_ID_MASK;
Ratan Guptacc6cdbf2017-09-01 23:06:25 +053065 ipsrc = ipmi::network::IPOrigin::UNSPECIFIED;
Patrick Venture585a1e92017-11-17 07:36:15 -080066 lan_set_in_progress = SET_COMPLETE;
Ratan Gupta7a7f0122018-03-07 12:31:05 +053067 flush = false;
Ratan Guptab8e99552017-07-27 07:07:48 +053068 }
Nan Li3d0df912016-10-18 19:51:41 +080069};
Patrick Venturec7c1c3c2017-11-15 14:29:18 -080070
71// Given a channel, get the corresponding configuration,
72// or allocate it first.
73//
74// @param[in] channel the channel
75// @return the ChannelConfig_t pointer.
76struct ChannelConfig_t* getChannelConfig(int channel);
Ratan Gupta7a7f0122018-03-07 12:31:05 +053077
78/** @brief Iterate over all the channelconfig and if
79 * user has given the data for a channel then
80 * apply the network changes for that channel.
81 */
82void commitNetworkChanges();
83
84/* @brief Apply the network changes which is there in the
85 * network cache for a given channel which gets filled
86 * through setLan command. If some of the network
87 * parameter was not given by the setLan then this function
88 * gets the value of that parameter which is already
89 * configured on the system.
90 * @param[in] channel: channel number.
91 */
92void applyChanges(int channel);