blob: 9f2cd400eebb828f135322887ebddccd74221c3d [file] [log] [blame]
Patrick Ventured26fff42018-09-18 15:37:59 -07001#pragma once
2
Patrick Ventureaca98132019-03-18 11:14:16 -07003#include "handler.hpp"
4
Patrick Venture08f879c2019-03-18 10:51:42 -07005#include <ipmid/api.h>
6
George Liu6b3e8202025-07-02 16:19:16 +08007#include <ipmid/api-types.hpp>
8
Patrick Ventured26fff42018-09-18 15:37:59 -07009#include <cstdint>
Patrick Ventureaca98132019-03-18 11:14:16 -070010#include <string>
Patrick Ventured26fff42018-09-18 15:37:59 -070011
12namespace ethstats
13{
14
15/**
16 * @brief Ethstat Request structure.
17 */
18struct EthStatRequest
19{
Patrick Venture08f879c2019-03-18 10:51:42 -070020 std::uint8_t statId;
21 std::uint8_t if_name_len;
Patrick Ventured26fff42018-09-18 15:37:59 -070022} __attribute__((packed));
23
24/**
25 * @brief Ethstat Reply structure.
26 */
27struct EthStatReply
28{
Patrick Venture08f879c2019-03-18 10:51:42 -070029 std::uint8_t statId;
30 std::uint64_t value;
Patrick Ventured26fff42018-09-18 15:37:59 -070031} __attribute__((packed));
32
33enum EthernetStatisticsIds
34{
35 RX_BYTES = 0,
36 RX_COMPRESSED = 1,
37 RX_CRC_ERRORS = 2,
38 RX_DROPPED = 3,
39 RX_ERRORS = 4,
40 RX_FIFO_ERRORS = 5,
41 RX_FRAME_ERRORS = 6,
42 RX_LENGTH_ERRORS = 7,
43 RX_MISSED_ERRORS = 8,
44 RX_NOHANDLER = 9,
45 RX_OVER_ERRORS = 10,
46 RX_PACKETS = 11,
47 TX_ABORTED_ERRORS = 12,
48 TX_BYTES = 13,
49 TX_CARRIER_ERRORS = 14,
50 TX_COMPRESSED = 15,
51 TX_DROPPED = 16,
52 TX_ERRORS = 17,
53 TX_FIFO_ERRORS = 18,
54 TX_HEARTBEAT_ERRORS = 19,
55 TX_PACKETS = 20,
56 TX_WINDOW_ERRORS = 21,
57};
58
Patrick Venture08f879c2019-03-18 10:51:42 -070059/**
60 * Handle the OEM IPMI EthStat Command.
61 *
Patrick Venture08f879c2019-03-18 10:51:42 -070062 * @param[in] reqBuf - the IPMI request buffer.
63 * @param[in,out] replyCmdBuf - the IPMI reply buffer.
64 * @param[in,out] dataLen - the length of the request and reply.
Patrick Ventureaca98132019-03-18 11:14:16 -070065 * @param[in] handler - pointer to ethstats implementation.
Patrick Venture08f879c2019-03-18 10:51:42 -070066 * @return the IPMI result code.
67 */
Patrick Ventureaca98132019-03-18 11:14:16 -070068ipmi_ret_t handleEthStatCommand(const std::uint8_t* reqBuf,
69 std::uint8_t* replyCmdBuf, size_t* dataLen,
Patrick Venture75ca0182020-05-13 18:36:36 -070070 const EthStatsInterface* handler);
Patrick Ventureaca98132019-03-18 11:14:16 -070071
72/**
73 * Given an ethernet if_name and a field, build the full path.
74 *
75 * @param[in] ifName - the ethernet interface's name.
76 * @param[in] field - the name of the statistic
77 * @return the full path of the file to read for the statistic for that
78 * interface name.
79 */
80std::string buildPath(const std::string& ifName, const std::string& field);
Patrick Venture08f879c2019-03-18 10:51:42 -070081
Patrick Ventured26fff42018-09-18 15:37:59 -070082} // namespace ethstats