blob: a04e249867ace7229a724583637048e7d5d73fb6 [file] [log] [blame]
Eddie Jamesfa1f5c02020-09-17 15:12:46 -05001#pragma once
2
3#include <span>
Jeremy Kerr8a76d892024-07-26 17:19:57 +08004#include <string>
Eddie Jamesfa1f5c02020-09-17 15:12:46 -05005
Ratan Guptabbe45792018-03-23 00:22:55 +05306namespace phosphor
7{
8namespace network
9{
10namespace ncsi
11{
12
Ratan Guptaed5d7ff2018-03-23 00:27:52 +053013constexpr auto DEFAULT_VALUE = -1;
14constexpr auto NONE = 0;
15
Jeremy Kerr8d9af022024-07-26 16:47:16 +080016struct Interface
17{
18 int ifindex;
19};
20
Jeremy Kerr8a76d892024-07-26 17:19:57 +080021std::string to_string(Interface& interface);
22
Ratan Guptabbe45792018-03-23 00:22:55 +053023/* @brief This function will ask underlying NCSI driver
Eddie Jamesfa1f5c02020-09-17 15:12:46 -050024 * 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 Kerr8d9af022024-07-26 16:47:16 +080028 * @param[in] interface - Interface
Eddie Jamesfa1f5c02020-09-17 15:12:46 -050029 * @param[in] package - NCSI Package.
30 * @param[in] channel - Channel number with in the package.
Johnathan Mantey1ebea282024-02-15 10:26:06 -080031 * @param[in] opcode - NCSI Send Command sub-operation
Eddie Jamesfa1f5c02020-09-17 15:12:46 -050032 * @param[in] payload - OEM data to send.
33 * @returns 0 on success and negative value for failure.
34 */
Jeremy Kerr8d9af022024-07-26 16:47:16 +080035int sendOemCommand(Interface& interface, int package, int channel, int opcode,
Eddie Jamesfa1f5c02020-09-17 15:12:46 -050036 std::span<const unsigned char> payload);
37
38/* @brief This function will ask underlying NCSI driver
Ratan Guptabbe45792018-03-23 00:22:55 +053039 * 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 Kerr8d9af022024-07-26 16:47:16 +080043 * @param[in] interface - Interface
Ratan Guptabbe45792018-03-23 00:22:55 +053044 * @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 Kerr8d9af022024-07-26 16:47:16 +080048int setChannel(Interface& interface, int package, int channel);
Ratan Guptabbe45792018-03-23 00:22:55 +053049
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 Kerr8d9af022024-07-26 16:47:16 +080055 * @param[in] interface - Interface
Ratan Guptabbe45792018-03-23 00:22:55 +053056 * @returns 0 on success and negative value for failure.
57 */
Jeremy Kerr8d9af022024-07-26 16:47:16 +080058int clearInterface(Interface& interface);
Ratan Guptabbe45792018-03-23 00:22:55 +053059
Ratan Guptaaac603e2018-03-23 00:25:54 +053060/* @brief This function is used to dump all the info
61 * of the package and the channels underlying
62 * the package.
Jeremy Kerr8d9af022024-07-26 16:47:16 +080063 * @param[in] interface - Interface
Ratan Guptaaac603e2018-03-23 00:25:54 +053064 * @param[in] package - NCSI Package.
65 * @returns 0 on success and negative value for failure.
66 */
Jeremy Kerr8d9af022024-07-26 16:47:16 +080067int getInfo(Interface& interface, int package);
Ratan Guptaaac603e2018-03-23 00:25:54 +053068
Johnathan Mantey5a456062024-02-15 08:45:08 -080069/* @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 Kerr8d9af022024-07-26 16:47:16 +080075int setPackageMask(Interface& interface, unsigned int mask);
Johnathan Mantey5a456062024-02-15 08:45:08 -080076
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 Kerr8d9af022024-07-26 16:47:16 +080084int setChannelMask(Interface& interface, int package, unsigned int mask);
Johnathan Mantey5a456062024-02-15 08:45:08 -080085
Gunnar Mills57d9c502018-09-14 14:42:34 -050086} // namespace ncsi
87} // namespace network
88} // namespace phosphor