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" |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 4 | |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 5 | #include <string> |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 6 | // IPMI commands for Transport net functions. |
| 7 | enum 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 |
| 15 | enum ipmi_transport_return_codes |
| 16 | { |
| 17 | IPMI_CC_PARM_NOT_SUPPORTED = 0x80, |
| 18 | }; |
| 19 | |
Adriana Kobylak | e08fbc6 | 2016-02-09 16:17:23 -0600 | [diff] [blame] | 20 | // Parameters |
William A. Kennington III | aab2023 | 2018-11-19 18:20:39 -0800 | [diff] [blame] | 21 | enum class LanParam : uint8_t |
William A. Kennington III | 7a3479e | 2018-11-19 17:41:20 -0800 | [diff] [blame] | 22 | { |
William A. Kennington III | aab2023 | 2018-11-19 18:20:39 -0800 | [diff] [blame] | 23 | 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 III | 7a3479e | 2018-11-19 17:41:20 -0800 | [diff] [blame] | 32 | CIPHER_SUITE_COUNT = 22, |
| 33 | CIPHER_SUITE_ENTRIES = 23, |
| 34 | }; |
Adriana Kobylak | e08fbc6 | 2016-02-09 16:17:23 -0600 | [diff] [blame] | 35 | |
Patrick Venture | 585a1e9 | 2017-11-17 07:36:15 -0800 | [diff] [blame] | 36 | constexpr uint8_t SET_COMPLETE = 0; |
| 37 | constexpr uint8_t SET_IN_PROGRESS = 1; |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 38 | constexpr uint8_t SET_COMMIT_WRITE = 2; // Optional |
| 39 | constexpr uint8_t SET_IN_PROGRESS_RESERVED = 3; // Reserved |
Patrick Venture | 585a1e9 | 2017-11-17 07:36:15 -0800 | [diff] [blame] | 40 | |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 41 | const int CHANNEL_MASK = 0x0f; |
| 42 | const int NUM_CHANNELS = 0x0f; |
| 43 | |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 44 | struct ChannelConfig_t |
| 45 | { |
| 46 | std::string ipaddr; |
Ratan Gupta | cc6cdbf | 2017-09-01 23:06:25 +0530 | [diff] [blame] | 47 | ipmi::network::IPOrigin ipsrc = ipmi::network::IPOrigin::UNSPECIFIED; |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 48 | std::string netmask; |
| 49 | std::string gateway; |
| 50 | std::string macAddress; |
Ratan Gupta | 533d03b | 2017-07-30 10:39:22 +0530 | [diff] [blame] | 51 | // 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 Venture | 585a1e9 | 2017-11-17 07:36:15 -0800 | [diff] [blame] | 55 | uint8_t lan_set_in_progress = SET_COMPLETE; |
Ratan Gupta | 7a7f012 | 2018-03-07 12:31:05 +0530 | [diff] [blame] | 56 | bool flush = false; |
Ratan Gupta | 533d03b | 2017-07-30 10:39:22 +0530 | [diff] [blame] | 57 | |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 58 | void clear() |
| 59 | { |
| 60 | ipaddr.clear(); |
| 61 | netmask.clear(); |
| 62 | gateway.clear(); |
| 63 | macAddress.clear(); |
Ratan Gupta | 533d03b | 2017-07-30 10:39:22 +0530 | [diff] [blame] | 64 | vlanID = ipmi::network::VLAN_ID_MASK; |
Ratan Gupta | cc6cdbf | 2017-09-01 23:06:25 +0530 | [diff] [blame] | 65 | ipsrc = ipmi::network::IPOrigin::UNSPECIFIED; |
Patrick Venture | 585a1e9 | 2017-11-17 07:36:15 -0800 | [diff] [blame] | 66 | lan_set_in_progress = SET_COMPLETE; |
Ratan Gupta | 7a7f012 | 2018-03-07 12:31:05 +0530 | [diff] [blame] | 67 | flush = false; |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 68 | } |
Nan Li | 3d0df91 | 2016-10-18 19:51:41 +0800 | [diff] [blame] | 69 | }; |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 70 | |
| 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. |
| 76 | struct ChannelConfig_t* getChannelConfig(int channel); |
Ratan Gupta | 7a7f012 | 2018-03-07 12:31:05 +0530 | [diff] [blame] | 77 | |
| 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 | */ |
| 82 | void 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 | */ |
| 92 | void applyChanges(int channel); |