// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

#include <ipmid/api-types.hpp>

#include <cstdint>
#include <map>
#include <span>
#include <string>
#include <string_view>
#include <tuple>
#include <vector>

namespace google
{
namespace ipmi
{

using Resp = ::ipmi::RspType<std::uint8_t, std::vector<uint8_t>>;

using VersionTuple =
    std::tuple<std::uint8_t, std::uint8_t, std::uint8_t, std::uint8_t>;

class HandlerInterface
{
  public:
    virtual ~HandlerInterface() = default;

    /**
     * Return the operation mode of BMC
     *
     * @return the BMC operation mode
     */
    virtual uint8_t getBmcMode() = 0;

    /**
     * Return ethernet details (hard-coded).
     *
     * @return tuple of ethernet details (channel, if name).
     */
    virtual std::tuple<std::uint8_t, std::string>
        getEthDetails(std::string intf) const = 0;

    /**
     * Return the value of rx_packets, given a if_name.
     *
     * @param[in] name, the interface name.
     * @return the number of packets received.
     * @throw IpmiException on failure.
     */
    virtual std::int64_t getRxPackets(const std::string& name) const = 0;

    /**
     * Return the values from a cpld version file.
     *
     * @param[in] id - the cpld id number.
     * @return the quad of numbers as a tuple (maj,min,pt,subpt)
     * @throw IpmiException on failure.
     */
    virtual VersionTuple getCpldVersion(unsigned int id) const = 0;

    /**
     * Set the PSU Reset delay.
     *
     * @param[in] delay - delay in seconds.
     * @throw IpmiException on failure.
     */
    virtual void psuResetDelay(std::uint32_t delay) const = 0;

    /**
     * Arm for PSU reset on host shutdown.
     *
     * @throw IpmiException on failure.
     */
    virtual void psuResetOnShutdown() const = 0;

    /**
     * Return the entity name.
     * On the first call to this method it'll build the list of entities.
     * @todo Consider moving the list building to construction time (and ignore
     * failures).
     *
     * @param[in] id - the entity id value
     * @param[in] instance - the entity instance
     * @return the entity's name
     * @throw IpmiException on failure.
     */
    virtual std::string getEntityName(std::uint8_t id,
                                      std::uint8_t instance) = 0;

    /**
     * Return the flash size of bmc chip.
     *
     * @return the flash size of bmc chip
     * @throw IpmiException on failure.
     */
    virtual uint32_t getFlashSize() = 0;

    /**
     * Return the name of the machine, parsed from release information.
     *
     * @return the machine name
     * @throw IpmiException on failure.
     */
    virtual std::string getMachineName() = 0;

    /**
     * Populate the i2c-pcie mapping vector.
     */
    virtual void buildI2cPcieMapping() = 0;

    /**
     * Return the size of the i2c-pcie mapping vector.
     *
     * @return the size of the vector holding the i2c-pcie mapping tuples.
     */
    virtual size_t getI2cPcieMappingSize() const = 0;

    /**
     * Return a copy of the entry in the vector.
     *
     * @param[in] entry - the index into the vector.
     * @return the tuple at that index.
     */
    virtual std::tuple<std::uint32_t, std::string>
        getI2cEntry(unsigned int entry) const = 0;

    /**
     * Set the Host Power Off delay.
     *
     * @param[in] delay - delay in seconds.
     * @throw IpmiException on failure.
     */
    virtual void hostPowerOffDelay(std::uint32_t delay) const = 0;

    /**
     * Return the number of devices from the CustomAccel service.
     *
     * @return the number of devices.
     * @throw IpmiException on failure.
     */
    virtual uint32_t accelOobDeviceCount() const = 0;

    /**
     * Return the name of a single device from the CustomAccel service.
     *
     * Valid indexes start at 0 and go up to (but don't include) the number of
     * devices. The number of devices can be queried with accelOobDeviceCount.
     *
     * @param[in] index - the index of the device, starting at 0.
     * @return the name of the device.
     * @throw IpmiException on failure.
     */
    virtual std::string accelOobDeviceName(size_t index) const = 0;

    /**
     * Read from a single CustomAccel service device.
     *
     * Valid device names can be queried with accelOobDeviceName.
     * If num_bytes < 8, all unused MSBs are padded with 0s.
     *
     * @param[in] name - the name of the device (from DeviceName).
     * @param[in] address - the address to read from.
     * @param[in] num_bytes - the size of the read, in bytes.
     * @return the data read, with 0s padding any unused MSBs.
     * @throw IpmiException on failure.
     */
    virtual uint64_t accelOobRead(std::string_view name, uint64_t address,
                                  uint8_t num_bytes) const = 0;

    /**
     * Write to a single CustomAccel service device.
     *
     * Valid device names can be queried with accelOobDeviceName.
     * If num_bytes < 8, all unused MSBs are ignored.
     *
     * @param[in] name - the name of the device (from DeviceName).
     * @param[in] address - the address to read from.
     * @param[in] num_bytes - the size of the read, in bytes.
     * @param[in] data - the data to write.
     * @throw IpmiException on failure.
     */
    virtual void accelOobWrite(std::string_view name, uint64_t address,
                               uint8_t num_bytes, uint64_t data) const = 0;

    /**
     * Parse the I2C tree to get the highest level of bifurcation in target bus.
     *
     * @param[in] index    - PCIe Slot Index
     * @return list of lanes taken by each device.
     */
    virtual std::vector<uint8_t> pcieBifurcation(uint8_t index) = 0;

    /**
     * Prepare for OS boot.
     *
     * If in bare metal mode, the BMC will disable IPMI, to protect against an
     * untrusted OS.
     */
    virtual void linuxBootDone() const = 0;
};

} // namespace ipmi
} // namespace google
