blob: 452c916099929cd3f77d7207dc550ac85a88c8ab [file] [log] [blame]
Eddie Jamesfa1f5c02020-09-17 15:12:46 -05001#pragma once
2
Jeremy Kerr7f7c0852024-08-08 11:32:55 +08003#include <stdint.h>
4
5#include <optional>
Eddie Jamesfa1f5c02020-09-17 15:12:46 -05006#include <span>
Jeremy Kerr8a76d892024-07-26 17:19:57 +08007#include <string>
Jeremy Kerr7f7c0852024-08-08 11:32:55 +08008#include <vector>
Eddie Jamesfa1f5c02020-09-17 15:12:46 -05009
Ratan Guptabbe45792018-03-23 00:22:55 +053010namespace phosphor
11{
12namespace network
13{
14namespace ncsi
15{
16
Ratan Guptaed5d7ff2018-03-23 00:27:52 +053017constexpr auto DEFAULT_VALUE = -1;
18constexpr auto NONE = 0;
19
Jeremy Kerr7f7c0852024-08-08 11:32:55 +080020struct 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
31struct PackageInfo
32{
33 uint32_t id;
34 bool forced;
35 std::vector<ChannelInfo> channels;
36};
37
38struct InterfaceInfo
39{
40 std::vector<PackageInfo> packages;
41};
42
Jeremy Kerr8d9af022024-07-26 16:47:16 +080043struct Interface
44{
Jeremy Kerrbc22f812024-07-29 17:43:35 +080045 /* @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 Kerr7f7c0852024-08-08 11:32:55 +080080 * 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 Kerrbc22f812024-07-29 17:43:35 +080085 */
Jeremy Kerr7f7c0852024-08-08 11:32:55 +080086 std::optional<InterfaceInfo> getInfo(int package);
Jeremy Kerrbc22f812024-07-29 17:43:35 +080087
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 Kerr8d9af022024-07-26 16:47:16 +0800103 int ifindex;
104};
105
Jeremy Kerr8a76d892024-07-26 17:19:57 +0800106std::string to_string(Interface& interface);
107
Gunnar Mills57d9c502018-09-14 14:42:34 -0500108} // namespace ncsi
109} // namespace network
110} // namespace phosphor