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