Eddie James | fa1f5c0 | 2020-09-17 15:12:46 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Jeremy Kerr | 7f7c085 | 2024-08-08 11:32:55 +0800 | [diff] [blame^] | 3 | #include <stdint.h> |
| 4 | |
| 5 | #include <optional> |
Eddie James | fa1f5c0 | 2020-09-17 15:12:46 -0500 | [diff] [blame] | 6 | #include <span> |
Jeremy Kerr | 8a76d89 | 2024-07-26 17:19:57 +0800 | [diff] [blame] | 7 | #include <string> |
Jeremy Kerr | 7f7c085 | 2024-08-08 11:32:55 +0800 | [diff] [blame^] | 8 | #include <vector> |
Eddie James | fa1f5c0 | 2020-09-17 15:12:46 -0500 | [diff] [blame] | 9 | |
Ratan Gupta | bbe4579 | 2018-03-23 00:22:55 +0530 | [diff] [blame] | 10 | namespace phosphor |
| 11 | { |
| 12 | namespace network |
| 13 | { |
| 14 | namespace ncsi |
| 15 | { |
| 16 | |
Ratan Gupta | ed5d7ff | 2018-03-23 00:27:52 +0530 | [diff] [blame] | 17 | constexpr auto DEFAULT_VALUE = -1; |
| 18 | constexpr auto NONE = 0; |
| 19 | |
Jeremy Kerr | 7f7c085 | 2024-08-08 11:32:55 +0800 | [diff] [blame^] | 20 | struct ChannelInfo |
| 21 | { |
| 22 | uint32_t id; |
| 23 | bool active; |
| 24 | bool forced; |
| 25 | uint32_t version_major, version_minor; |
| 26 | std::string version; |
| 27 | uint32_t link_state; |
| 28 | std::vector<uint16_t> vlan_ids; |
| 29 | }; |
| 30 | |
| 31 | struct PackageInfo |
| 32 | { |
| 33 | uint32_t id; |
| 34 | bool forced; |
| 35 | std::vector<ChannelInfo> channels; |
| 36 | }; |
| 37 | |
| 38 | struct InterfaceInfo |
| 39 | { |
| 40 | std::vector<PackageInfo> packages; |
| 41 | }; |
| 42 | |
Jeremy Kerr | 8d9af02 | 2024-07-26 16:47:16 +0800 | [diff] [blame] | 43 | struct Interface |
| 44 | { |
Jeremy Kerr | bc22f81 | 2024-07-29 17:43:35 +0800 | [diff] [blame] | 45 | /* @brief This function will ask underlying NCSI driver |
| 46 | * to send an OEM command (command type 0x50) with |
| 47 | * the specified payload as the OEM data. |
| 48 | * This function talks with the NCSI driver over |
| 49 | * netlink messages. |
| 50 | * @param[in] package - NCSI Package. |
| 51 | * @param[in] channel - Channel number with in the package. |
| 52 | * @param[in] opcode - NCSI Send Command sub-operation |
| 53 | * @param[in] payload - OEM data to send. |
| 54 | * @returns 0 on success and negative value for failure. |
| 55 | */ |
| 56 | int sendOemCommand(int package, int channel, int opcode, |
| 57 | std::span<const unsigned char> payload); |
| 58 | |
| 59 | /* @brief This function will ask underlying NCSI driver |
| 60 | * to set a specific package or package/channel |
| 61 | * combination as the preferred choice. |
| 62 | * This function talks with the NCSI driver over |
| 63 | * netlink messages. |
| 64 | * @param[in] package - NCSI Package. |
| 65 | * @param[in] channel - Channel number with in the package. |
| 66 | * @returns 0 on success and negative value for failure. |
| 67 | */ |
| 68 | int setChannel(int package, int channel); |
| 69 | |
| 70 | /* @brief This function will ask underlying NCSI driver |
| 71 | * to clear any preferred setting from the interface. |
| 72 | * This function talks with the NCSI driver over |
| 73 | * netlink messages. |
| 74 | * @returns 0 on success and negative value for failure. |
| 75 | */ |
| 76 | int clearInterface(); |
| 77 | |
| 78 | /* @brief This function is used to dump all the info |
| 79 | * of the package and the channels underlying |
Jeremy Kerr | 7f7c085 | 2024-08-08 11:32:55 +0800 | [diff] [blame^] | 80 | * the package, or all packages if DEFAULT_VALUE |
| 81 | * is passed |
| 82 | * @param[in] package - NCSI Package |
| 83 | * @returns an InterfaceInfo with package data the specified pacakge, |
| 84 | * or all packages if none is specified. |
Jeremy Kerr | bc22f81 | 2024-07-29 17:43:35 +0800 | [diff] [blame] | 85 | */ |
Jeremy Kerr | 7f7c085 | 2024-08-08 11:32:55 +0800 | [diff] [blame^] | 86 | std::optional<InterfaceInfo> getInfo(int package); |
Jeremy Kerr | bc22f81 | 2024-07-29 17:43:35 +0800 | [diff] [blame] | 87 | |
| 88 | /* @brief This function assigns a mask controlling responses to AEN from a |
| 89 | * package. |
| 90 | * @param[in] mask - A 32-bit mask integer |
| 91 | * @returns 0 on success and negative value for failure. |
| 92 | */ |
| 93 | int setPackageMask(unsigned int mask); |
| 94 | |
| 95 | /* @brief This function sets the AEN mask for the channels inside the |
| 96 | * selected package. |
| 97 | * @param[in] package - NCSI Package. |
| 98 | * @param[in] mask - A 32-bit mask integer |
| 99 | * @returns 0 on success and negative value for failure. |
| 100 | */ |
| 101 | int setChannelMask(int package, unsigned int mask); |
| 102 | |
Jeremy Kerr | 8d9af02 | 2024-07-26 16:47:16 +0800 | [diff] [blame] | 103 | int ifindex; |
| 104 | }; |
| 105 | |
Jeremy Kerr | 8a76d89 | 2024-07-26 17:19:57 +0800 | [diff] [blame] | 106 | std::string to_string(Interface& interface); |
| 107 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 108 | } // namespace ncsi |
| 109 | } // namespace network |
| 110 | } // namespace phosphor |