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