Patrick Venture | d26fff4 | 2018-09-18 15:37:59 -0700 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Patrick Venture | aca9813 | 2019-03-18 11:14:16 -0700 | [diff] [blame] | 3 | #include "handler.hpp" |
| 4 | |
Patrick Venture | 08f879c | 2019-03-18 10:51:42 -0700 | [diff] [blame] | 5 | #include <ipmid/api.h> |
| 6 | |
Patrick Venture | d26fff4 | 2018-09-18 15:37:59 -0700 | [diff] [blame] | 7 | #include <cstdint> |
Patrick Venture | aca9813 | 2019-03-18 11:14:16 -0700 | [diff] [blame] | 8 | #include <string> |
Patrick Venture | d26fff4 | 2018-09-18 15:37:59 -0700 | [diff] [blame] | 9 | |
| 10 | namespace ethstats |
| 11 | { |
| 12 | |
| 13 | /** |
| 14 | * @brief Ethstat Request structure. |
| 15 | */ |
| 16 | struct EthStatRequest |
| 17 | { |
Patrick Venture | 08f879c | 2019-03-18 10:51:42 -0700 | [diff] [blame] | 18 | std::uint8_t statId; |
| 19 | std::uint8_t if_name_len; |
Patrick Venture | d26fff4 | 2018-09-18 15:37:59 -0700 | [diff] [blame] | 20 | } __attribute__((packed)); |
| 21 | |
| 22 | /** |
| 23 | * @brief Ethstat Reply structure. |
| 24 | */ |
| 25 | struct EthStatReply |
| 26 | { |
Patrick Venture | 08f879c | 2019-03-18 10:51:42 -0700 | [diff] [blame] | 27 | std::uint8_t statId; |
| 28 | std::uint64_t value; |
Patrick Venture | d26fff4 | 2018-09-18 15:37:59 -0700 | [diff] [blame] | 29 | } __attribute__((packed)); |
| 30 | |
| 31 | enum 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 Venture | 08f879c | 2019-03-18 10:51:42 -0700 | [diff] [blame] | 57 | /** |
| 58 | * Handle the OEM IPMI EthStat Command. |
| 59 | * |
Patrick Venture | 08f879c | 2019-03-18 10:51:42 -0700 | [diff] [blame] | 60 | * @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 Venture | aca9813 | 2019-03-18 11:14:16 -0700 | [diff] [blame] | 63 | * @param[in] handler - pointer to ethstats implementation. |
Patrick Venture | 08f879c | 2019-03-18 10:51:42 -0700 | [diff] [blame] | 64 | * @return the IPMI result code. |
| 65 | */ |
Patrick Venture | aca9813 | 2019-03-18 11:14:16 -0700 | [diff] [blame] | 66 | ipmi_ret_t handleEthStatCommand(const std::uint8_t* reqBuf, |
| 67 | std::uint8_t* replyCmdBuf, size_t* dataLen, |
Patrick Venture | 75ca018 | 2020-05-13 18:36:36 -0700 | [diff] [blame] | 68 | const EthStatsInterface* handler); |
Patrick Venture | aca9813 | 2019-03-18 11:14:16 -0700 | [diff] [blame] | 69 | |
| 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 | */ |
| 78 | std::string buildPath(const std::string& ifName, const std::string& field); |
Patrick Venture | 08f879c | 2019-03-18 10:51:42 -0700 | [diff] [blame] | 79 | |
Patrick Venture | d26fff4 | 2018-09-18 15:37:59 -0700 | [diff] [blame] | 80 | } // namespace ethstats |