blob: 9020809ca66bb76e13e4c77368576afeb1d72859 [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
29static ipmi_ret_t ethStatCommand(ipmi_cmd_t cmd __attribute__((unused)),
30 const uint8_t* reqBuf, uint8_t* replyCmdBuf,
31 size_t* dataLen)
32{
33 return handleEthStatCommand(reqBuf, replyCmdBuf, dataLen);
34}
35
36} // namespace ethstats
37
Patrick Ventured26fff42018-09-18 15:37:59 -070038void setupGlobalOemEthStats() __attribute__((constructor));
39
40void setupGlobalOemEthStats()
41{
42 oem::Router* oemRouter = oem::mutableRouter();
43
Patrick Ventured72f8b52019-03-07 16:54:57 -080044#if ENABLE_GOOGLE
Patrick Ventured26fff42018-09-18 15:37:59 -070045 /* Install in Google OEM Namespace when enabled. */
46 std::fprintf(stderr,
47 "Registering OEM:[%#08X], Cmd:[%#04X] for Ethstats Commands\n",
Patrick Ventureddee9d02018-11-15 14:50:52 -080048 oem::googOemNumber, oem::Cmd::ethStatsCmd);
Patrick Ventured26fff42018-09-18 15:37:59 -070049
Patrick Ventureddee9d02018-11-15 14:50:52 -080050 oemRouter->registerHandler(oem::googOemNumber, oem::Cmd::ethStatsCmd,
Patrick Ventureaca98132019-03-18 11:14:16 -070051 ethstats::ethStatCommand);
Patrick Ventured26fff42018-09-18 15:37:59 -070052#endif
53
54 std::fprintf(stderr,
55 "Registering OEM:[%#08X], Cmd:[%#04X] for Ethstats Commands\n",
Patrick Ventureddee9d02018-11-15 14:50:52 -080056 oem::obmcOemNumber, oem::Cmd::ethStatsCmd);
Patrick Ventured26fff42018-09-18 15:37:59 -070057
Patrick Ventureddee9d02018-11-15 14:50:52 -080058 oemRouter->registerHandler(oem::obmcOemNumber, oem::Cmd::ethStatsCmd,
Patrick Ventureaca98132019-03-18 11:14:16 -070059 ethstats::ethStatCommand);
Patrick Ventured26fff42018-09-18 15:37:59 -070060}