blob: 34278b176708e8502656793bbdf1fca8e685cbd2 [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
William A. Kennington III539f03f2019-02-12 13:28:45 -080021#include <ipmid/iana.hpp>
22#include <ipmid/oemopenbmc.hpp>
23#include <ipmid/oemrouter.hpp>
Patrick Ventured26fff42018-09-18 15:37:59 -070024
Patrick Williams4cf2bef2023-05-10 07:51:36 -050025#include <cstdio>
26
Patrick Ventureaca98132019-03-18 11:14:16 -070027namespace ethstats
28{
29
Patrick Venture75ca0182020-05-13 18:36:36 -070030EthStats handler;
31
Patrick Ventureaca98132019-03-18 11:14:16 -070032static ipmi_ret_t ethStatCommand(ipmi_cmd_t cmd __attribute__((unused)),
33 const uint8_t* reqBuf, uint8_t* replyCmdBuf,
34 size_t* dataLen)
35{
Patrick Venture75ca0182020-05-13 18:36:36 -070036 return handleEthStatCommand(reqBuf, replyCmdBuf, dataLen, &handler);
Patrick Ventureaca98132019-03-18 11:14:16 -070037}
38
39} // namespace ethstats
40
Patrick Ventured26fff42018-09-18 15:37:59 -070041void setupGlobalOemEthStats() __attribute__((constructor));
42
43void setupGlobalOemEthStats()
44{
45 oem::Router* oemRouter = oem::mutableRouter();
46
Patrick Ventured72f8b52019-03-07 16:54:57 -080047#if ENABLE_GOOGLE
Patrick Ventured26fff42018-09-18 15:37:59 -070048 /* Install in Google OEM Namespace when enabled. */
49 std::fprintf(stderr,
50 "Registering OEM:[%#08X], Cmd:[%#04X] for Ethstats Commands\n",
Patrick Ventureddee9d02018-11-15 14:50:52 -080051 oem::googOemNumber, oem::Cmd::ethStatsCmd);
Patrick Ventured26fff42018-09-18 15:37:59 -070052
Patrick Ventureddee9d02018-11-15 14:50:52 -080053 oemRouter->registerHandler(oem::googOemNumber, oem::Cmd::ethStatsCmd,
Patrick Ventureaca98132019-03-18 11:14:16 -070054 ethstats::ethStatCommand);
Patrick Ventured26fff42018-09-18 15:37:59 -070055#endif
56
57 std::fprintf(stderr,
58 "Registering OEM:[%#08X], Cmd:[%#04X] for Ethstats Commands\n",
Patrick Ventureddee9d02018-11-15 14:50:52 -080059 oem::obmcOemNumber, oem::Cmd::ethStatsCmd);
Patrick Ventured26fff42018-09-18 15:37:59 -070060
Patrick Ventureddee9d02018-11-15 14:50:52 -080061 oemRouter->registerHandler(oem::obmcOemNumber, oem::Cmd::ethStatsCmd,
Patrick Ventureaca98132019-03-18 11:14:16 -070062 ethstats::ethStatCommand);
Patrick Ventured26fff42018-09-18 15:37:59 -070063}