blob: e45d878a2fc49bf370fd7db0c5128d6d3a962ac6 [file] [log] [blame]
Patrick Ventured26fff42018-09-18 15:37:59 -07001/*
2 * Copyright 2018 Google Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "config.h"
18
19#include "ethstats.hpp"
20
Patrick Venture08f879c2019-03-18 10:51:42 -070021#include <cstdio>
William A. Kennington III539f03f2019-02-12 13:28:45 -080022#include <ipmid/iana.hpp>
23#include <ipmid/oemopenbmc.hpp>
24#include <ipmid/oemrouter.hpp>
Patrick Ventured26fff42018-09-18 15:37:59 -070025
Patrick Ventureaca98132019-03-18 11:14:16 -070026namespace ethstats
27{
28
Patrick Venture75ca0182020-05-13 18:36:36 -070029EthStats handler;
30
Patrick Ventureaca98132019-03-18 11:14:16 -070031static ipmi_ret_t ethStatCommand(ipmi_cmd_t cmd __attribute__((unused)),
32 const uint8_t* reqBuf, uint8_t* replyCmdBuf,
33 size_t* dataLen)
34{
Patrick Venture75ca0182020-05-13 18:36:36 -070035 return handleEthStatCommand(reqBuf, replyCmdBuf, dataLen, &handler);
Patrick Ventureaca98132019-03-18 11:14:16 -070036}
37
38} // namespace ethstats
39
Patrick Ventured26fff42018-09-18 15:37:59 -070040void setupGlobalOemEthStats() __attribute__((constructor));
41
42void setupGlobalOemEthStats()
43{
44 oem::Router* oemRouter = oem::mutableRouter();
45
Patrick Ventured72f8b52019-03-07 16:54:57 -080046#if ENABLE_GOOGLE
Patrick Ventured26fff42018-09-18 15:37:59 -070047 /* Install in Google OEM Namespace when enabled. */
48 std::fprintf(stderr,
49 "Registering OEM:[%#08X], Cmd:[%#04X] for Ethstats Commands\n",
Patrick Ventureddee9d02018-11-15 14:50:52 -080050 oem::googOemNumber, oem::Cmd::ethStatsCmd);
Patrick Ventured26fff42018-09-18 15:37:59 -070051
Patrick Ventureddee9d02018-11-15 14:50:52 -080052 oemRouter->registerHandler(oem::googOemNumber, oem::Cmd::ethStatsCmd,
Patrick Ventureaca98132019-03-18 11:14:16 -070053 ethstats::ethStatCommand);
Patrick Ventured26fff42018-09-18 15:37:59 -070054#endif
55
56 std::fprintf(stderr,
57 "Registering OEM:[%#08X], Cmd:[%#04X] for Ethstats Commands\n",
Patrick Ventureddee9d02018-11-15 14:50:52 -080058 oem::obmcOemNumber, oem::Cmd::ethStatsCmd);
Patrick Ventured26fff42018-09-18 15:37:59 -070059
Patrick Ventureddee9d02018-11-15 14:50:52 -080060 oemRouter->registerHandler(oem::obmcOemNumber, oem::Cmd::ethStatsCmd,
Patrick Ventureaca98132019-03-18 11:14:16 -070061 ethstats::ethStatCommand);
Patrick Ventured26fff42018-09-18 15:37:59 -070062}