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 |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 21 | static const int LAN_PARM_INPROGRESS = 0; |
Adriana Kobylak | e08fbc6 | 2016-02-09 16:17:23 -0600 | [diff] [blame] | 22 | static const int LAN_PARM_AUTHSUPPORT = 1; |
| 23 | static const int LAN_PARM_AUTHENABLES = 2; |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 24 | static const int LAN_PARM_IP = 3; |
| 25 | static const int LAN_PARM_IPSRC = 4; |
| 26 | static const int LAN_PARM_MAC = 5; |
| 27 | static const int LAN_PARM_SUBNET = 6; |
| 28 | static const int LAN_PARM_GATEWAY = 12; |
| 29 | static const int LAN_PARM_VLAN = 20; |
| 30 | static const int CIPHER_SUITE_COUNT = 22; |
Tom Joseph | a30c8d3 | 2018-03-22 02:15:03 +0530 | [diff] [blame] | 31 | static const int CIPHER_SUITE_ENTRIES = 23; |
Adriana Kobylak | e08fbc6 | 2016-02-09 16:17:23 -0600 | [diff] [blame] | 32 | |
Patrick Venture | 585a1e9 | 2017-11-17 07:36:15 -0800 | [diff] [blame] | 33 | constexpr uint8_t SET_COMPLETE = 0; |
| 34 | constexpr uint8_t SET_IN_PROGRESS = 1; |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 35 | constexpr uint8_t SET_COMMIT_WRITE = 2; // Optional |
| 36 | constexpr uint8_t SET_IN_PROGRESS_RESERVED = 3; // Reserved |
Patrick Venture | 585a1e9 | 2017-11-17 07:36:15 -0800 | [diff] [blame] | 37 | |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 38 | const int CHANNEL_MASK = 0x0f; |
| 39 | const int NUM_CHANNELS = 0x0f; |
| 40 | |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 41 | struct ChannelConfig_t |
| 42 | { |
| 43 | std::string ipaddr; |
Ratan Gupta | cc6cdbf | 2017-09-01 23:06:25 +0530 | [diff] [blame] | 44 | ipmi::network::IPOrigin ipsrc = ipmi::network::IPOrigin::UNSPECIFIED; |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 45 | std::string netmask; |
| 46 | std::string gateway; |
| 47 | std::string macAddress; |
Ratan Gupta | 533d03b | 2017-07-30 10:39:22 +0530 | [diff] [blame] | 48 | // 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 Venture | 585a1e9 | 2017-11-17 07:36:15 -0800 | [diff] [blame] | 52 | uint8_t lan_set_in_progress = SET_COMPLETE; |
Ratan Gupta | 7a7f012 | 2018-03-07 12:31:05 +0530 | [diff] [blame] | 53 | bool flush = false; |
Ratan Gupta | 533d03b | 2017-07-30 10:39:22 +0530 | [diff] [blame] | 54 | |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 55 | void clear() |
| 56 | { |
| 57 | ipaddr.clear(); |
| 58 | netmask.clear(); |
| 59 | gateway.clear(); |
| 60 | macAddress.clear(); |
Ratan Gupta | 533d03b | 2017-07-30 10:39:22 +0530 | [diff] [blame] | 61 | vlanID = ipmi::network::VLAN_ID_MASK; |
Ratan Gupta | cc6cdbf | 2017-09-01 23:06:25 +0530 | [diff] [blame] | 62 | ipsrc = ipmi::network::IPOrigin::UNSPECIFIED; |
Patrick Venture | 585a1e9 | 2017-11-17 07:36:15 -0800 | [diff] [blame] | 63 | lan_set_in_progress = SET_COMPLETE; |
Ratan Gupta | 7a7f012 | 2018-03-07 12:31:05 +0530 | [diff] [blame] | 64 | flush = false; |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 65 | } |
Nan Li | 3d0df91 | 2016-10-18 19:51:41 +0800 | [diff] [blame] | 66 | }; |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 67 | |
| 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. |
| 73 | struct ChannelConfig_t* getChannelConfig(int channel); |
Ratan Gupta | 7a7f012 | 2018-03-07 12:31:05 +0530 | [diff] [blame] | 74 | |
| 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 | */ |
| 79 | void 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 | */ |
| 89 | void applyChanges(int channel); |