Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Ratan Gupta | 533d03b | 2017-07-30 10:39:22 +0530 | [diff] [blame] | 3 | #include "types.hpp" |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 4 | #include <string> |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 5 | // IPMI commands for Transport net functions. |
| 6 | enum ipmi_netfn_storage_cmds |
| 7 | { |
| 8 | // Get capability bits |
| 9 | IPMI_CMD_SET_LAN = 0x01, |
| 10 | IPMI_CMD_GET_LAN = 0x02, |
| 11 | }; |
| 12 | |
| 13 | // Command specific completion codes |
| 14 | enum ipmi_transport_return_codes |
| 15 | { |
| 16 | IPMI_CC_PARM_NOT_SUPPORTED = 0x80, |
| 17 | }; |
| 18 | |
Adriana Kobylak | e08fbc6 | 2016-02-09 16:17:23 -0600 | [diff] [blame] | 19 | // Parameters |
| 20 | static const int LAN_PARM_INPROGRESS = 0; |
| 21 | static const int LAN_PARM_AUTHSUPPORT = 1; |
| 22 | static const int LAN_PARM_AUTHENABLES = 2; |
| 23 | static const int LAN_PARM_IP = 3; |
Ratan Gupta | cc6cdbf | 2017-09-01 23:06:25 +0530 | [diff] [blame] | 24 | static const int LAN_PARM_IPSRC = 4; |
Adriana Kobylak | e08fbc6 | 2016-02-09 16:17:23 -0600 | [diff] [blame] | 25 | static const int LAN_PARM_MAC = 5; |
| 26 | static const int LAN_PARM_SUBNET = 6; |
| 27 | static const int LAN_PARM_GATEWAY = 12; |
Ratan Gupta | 533d03b | 2017-07-30 10:39:22 +0530 | [diff] [blame] | 28 | static const int LAN_PARM_VLAN = 20; |
Tom Joseph | a30c8d3 | 2018-03-22 02:15:03 +0530 | [diff] [blame] | 29 | static const int CIPHER_SUITE_COUNT = 22; |
| 30 | static const int CIPHER_SUITE_ENTRIES = 23; |
Adriana Kobylak | e08fbc6 | 2016-02-09 16:17:23 -0600 | [diff] [blame] | 31 | |
Patrick Venture | 585a1e9 | 2017-11-17 07:36:15 -0800 | [diff] [blame] | 32 | constexpr uint8_t SET_COMPLETE = 0; |
| 33 | constexpr uint8_t SET_IN_PROGRESS = 1; |
| 34 | constexpr uint8_t SET_COMMIT_WRITE = 2; //Optional |
| 35 | constexpr uint8_t SET_IN_PROGRESS_RESERVED = 3; //Reserved |
| 36 | |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 37 | const int CHANNEL_MASK = 0x0f; |
| 38 | const int NUM_CHANNELS = 0x0f; |
| 39 | |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 40 | struct ChannelConfig_t |
| 41 | { |
| 42 | std::string ipaddr; |
Ratan Gupta | cc6cdbf | 2017-09-01 23:06:25 +0530 | [diff] [blame] | 43 | ipmi::network::IPOrigin ipsrc = ipmi::network::IPOrigin::UNSPECIFIED; |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 44 | std::string netmask; |
| 45 | std::string gateway; |
| 46 | std::string macAddress; |
Ratan Gupta | 533d03b | 2017-07-30 10:39:22 +0530 | [diff] [blame] | 47 | // IPMI stores the vlan info in 16 bits,32 bits is to aligned |
| 48 | // with phosphor-dbus interfaces. |
| 49 | // vlan id is in 12 bits and the 16th bit is for enable mask. |
| 50 | uint32_t vlanID = ipmi::network::VLAN_ID_MASK; |
Patrick Venture | 585a1e9 | 2017-11-17 07:36:15 -0800 | [diff] [blame] | 51 | uint8_t lan_set_in_progress = SET_COMPLETE; |
Ratan Gupta | 7a7f012 | 2018-03-07 12:31:05 +0530 | [diff] [blame] | 52 | bool flush = false; |
Ratan Gupta | 533d03b | 2017-07-30 10:39:22 +0530 | [diff] [blame] | 53 | |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 54 | void clear() |
| 55 | { |
| 56 | ipaddr.clear(); |
| 57 | netmask.clear(); |
| 58 | gateway.clear(); |
| 59 | macAddress.clear(); |
Ratan Gupta | 533d03b | 2017-07-30 10:39:22 +0530 | [diff] [blame] | 60 | vlanID = ipmi::network::VLAN_ID_MASK; |
Ratan Gupta | cc6cdbf | 2017-09-01 23:06:25 +0530 | [diff] [blame] | 61 | ipsrc = ipmi::network::IPOrigin::UNSPECIFIED; |
Patrick Venture | 585a1e9 | 2017-11-17 07:36:15 -0800 | [diff] [blame] | 62 | lan_set_in_progress = SET_COMPLETE; |
Ratan Gupta | 7a7f012 | 2018-03-07 12:31:05 +0530 | [diff] [blame] | 63 | flush = false; |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 64 | } |
Nan Li | 3d0df91 | 2016-10-18 19:51:41 +0800 | [diff] [blame] | 65 | }; |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 66 | |
| 67 | // Given a channel, get the corresponding configuration, |
| 68 | // or allocate it first. |
| 69 | // |
| 70 | // @param[in] channel the channel |
| 71 | // @return the ChannelConfig_t pointer. |
| 72 | struct ChannelConfig_t* getChannelConfig(int channel); |
Ratan Gupta | 7a7f012 | 2018-03-07 12:31:05 +0530 | [diff] [blame] | 73 | |
| 74 | /** @brief Iterate over all the channelconfig and if |
| 75 | * user has given the data for a channel then |
| 76 | * apply the network changes for that channel. |
| 77 | */ |
| 78 | void commitNetworkChanges(); |
| 79 | |
| 80 | /* @brief Apply the network changes which is there in the |
| 81 | * network cache for a given channel which gets filled |
| 82 | * through setLan command. If some of the network |
| 83 | * parameter was not given by the setLan then this function |
| 84 | * gets the value of that parameter which is already |
| 85 | * configured on the system. |
| 86 | * @param[in] channel: channel number. |
| 87 | */ |
| 88 | void applyChanges(int channel); |