blob: 520ed15abb9e0a02a024e7671f3268cb2722f4db [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
Patrick Ventured26fff42018-09-18 15:37:59 -07007#include <cstdint>
Patrick Ventureaca98132019-03-18 11:14:16 -07008#include <string>
Patrick Ventured26fff42018-09-18 15:37:59 -07009
10namespace ethstats
11{
12
13/**
14 * @brief Ethstat Request structure.
15 */
16struct EthStatRequest
17{
Patrick Venture08f879c2019-03-18 10:51:42 -070018 std::uint8_t statId;
19 std::uint8_t if_name_len;
Patrick Ventured26fff42018-09-18 15:37:59 -070020} __attribute__((packed));
21
22/**
23 * @brief Ethstat Reply structure.
24 */
25struct EthStatReply
26{
Patrick Venture08f879c2019-03-18 10:51:42 -070027 std::uint8_t statId;
28 std::uint64_t value;
Patrick Ventured26fff42018-09-18 15:37:59 -070029} __attribute__((packed));
30
31enum EthernetStatisticsIds
32{
33 RX_BYTES = 0,
34 RX_COMPRESSED = 1,
35 RX_CRC_ERRORS = 2,
36 RX_DROPPED = 3,
37 RX_ERRORS = 4,
38 RX_FIFO_ERRORS = 5,
39 RX_FRAME_ERRORS = 6,
40 RX_LENGTH_ERRORS = 7,
41 RX_MISSED_ERRORS = 8,
42 RX_NOHANDLER = 9,
43 RX_OVER_ERRORS = 10,
44 RX_PACKETS = 11,
45 TX_ABORTED_ERRORS = 12,
46 TX_BYTES = 13,
47 TX_CARRIER_ERRORS = 14,
48 TX_COMPRESSED = 15,
49 TX_DROPPED = 16,
50 TX_ERRORS = 17,
51 TX_FIFO_ERRORS = 18,
52 TX_HEARTBEAT_ERRORS = 19,
53 TX_PACKETS = 20,
54 TX_WINDOW_ERRORS = 21,
55};
56
Patrick Venture08f879c2019-03-18 10:51:42 -070057/**
58 * Handle the OEM IPMI EthStat Command.
59 *
Patrick Venture08f879c2019-03-18 10:51:42 -070060 * @param[in] reqBuf - the IPMI request buffer.
61 * @param[in,out] replyCmdBuf - the IPMI reply buffer.
62 * @param[in,out] dataLen - the length of the request and reply.
Patrick Ventureaca98132019-03-18 11:14:16 -070063 * @param[in] handler - pointer to ethstats implementation.
Patrick Venture08f879c2019-03-18 10:51:42 -070064 * @return the IPMI result code.
65 */
Patrick Ventureaca98132019-03-18 11:14:16 -070066ipmi_ret_t handleEthStatCommand(const std::uint8_t* reqBuf,
67 std::uint8_t* replyCmdBuf, size_t* dataLen,
Patrick Venture75ca0182020-05-13 18:36:36 -070068 const EthStatsInterface* handler);
Patrick Ventureaca98132019-03-18 11:14:16 -070069
70/**
71 * Given an ethernet if_name and a field, build the full path.
72 *
73 * @param[in] ifName - the ethernet interface's name.
74 * @param[in] field - the name of the statistic
75 * @return the full path of the file to read for the statistic for that
76 * interface name.
77 */
78std::string buildPath(const std::string& ifName, const std::string& field);
Patrick Venture08f879c2019-03-18 10:51:42 -070079
Patrick Ventured26fff42018-09-18 15:37:59 -070080} // namespace ethstats